XML Validator

by | Dec 25, 2020 | Website Development

Home » Website Development » XML Validator

Table of Contents

Why XML Validator

We have already discussed that an XML should have code written in such a way that each tag is closed at correct position. Sometimes, we forget to close a tag and if the length of the code is too long, then it becomes tedious to find out the missing tag. In such cases, we can use a XML validator.


Suppose you have a big piece of code as shown below:

<mvc:View controllerName="RuDeLabs.RuDeLabs.controller.Main" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
    xmlns="sap.m" xmlns:upload="sap.m.upload">
    <Shell id="shell">
        <App id="app">
                <Page id="page" title="{i18n>title}" titleAlignment="Center">
                                <Title text="{i18n>title}"/>
                                <Button text="Reset" press="onReset"/>
                    <VBox height="100%" alignItems="Center">
                        <HBox height="100%">
                                <Label design="Bold" text="Update Existing Document" required="true"/>
                                <Switch id="idSwitch" state="false" customTextOn="Yes" customTextOff="No"/>
                                <Label design="Bold" text="{i18n>collection}" required="true"/>
                                <Input width="300px" id="idCollection" required="true"/>
                                <Label design="Bold" text="{i18n>docs}" required="true"/>
                                <Select id="idType" selectedKey="text" width="100%" change="onSelectType">
                                    <core:Item key="text" text="Text"/>
                                    <core:Item key="images" text="Images"/>
                                    <core:Item key="stickers" text="Stickers"/>
                                <VBox id="idVBoxLangu">
                                    <Label design="Bold" text="{i18n>langu}" required="true"/>
                                    <Select id="idLangu" selectedKey="English" width="100%" change="onSelectLangu">
                                        <core:Item key="Arabic" text="Arabic"/>
                                        <core:Item key="Bengali" text="Bengali"/>
                                        <core:Item key="English" text="English"/>
                                        <core:Item key="French" text="French"/>
                                        <core:Item key="German" text="German"/>
                                        <core:Item key="Hebrew" text="Hebrew"/>
                                        <core:Item key="Hindi" text="Hindi"/>
                                        <core:Item key="Italian" text="Italian"/>
                                        <core:Item key="Punjabi" text="Punjabi"/>
                                        <core:Item key="Russian" text="Russian"/>
                                        <core:Item key="Spanish" text="Spanish"/>
                                <Label id="idContent" design="Bold" text="Your Content" required="true" design="Bold"/>
                                <TextArea id="idData" width="300px" placeholder="Enter your content, verify spaces and press verify button below."/>
                                <Button text="Verify" width="100%" press="onInputChange"/>
                                <UploadCollection id="idMultiUploader" visible="false" maximumFilenameLength="55" maximumFileSize="10" multiple="true"
                                    sameFilenameAllowed="false" instantUpload="false" change="onChangeUpload" fileDeleted="onFileDeleted" fileType="png"
                                    filenameLengthExceed="onFilenameLengthExceed" fileSizeExceed="onFileSizeExceed" typeMissmatch="onTypeMissmatch"
                                    uploadComplete="onUploadComplete" beforeUploadStarts="onBeforeUploadStarts"/>
                                <TextArea id="idTextArea" editable="false" growing="false" width="300px" visible="false"/>
                            <Text text="Ver 1.3"/>
                            <Button text="Push Data" press="onAddDateToCollection"/>

Now the above XML snippet is not working and you are confused, what is wrong with the above code. In cases like this, where you are not sure and the error is not visible, we check the above XML data with a validator tool.
After running the same, we get given output.

XML Validator

Based upon above findings, we can easily fix our code.



Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.