Validator in XML

In this article I have described the XML Valodator in XML.
  • 1907

INTRODUCTION

The validate XML files against a schema, or just validate the schema file by itself. This is important for many reasons but the most typical usage scenario is to group multiple validation rules that apply to the same value. you will have one or more validator definitions for each piece of data that you want to validate. NET has several built-in validator that are sufficient for most validations, even fairly complex ones. Really the only important prerequisite is that the XML file should point to the correct schema file inside the XML. This only checks if your XML is "Well formed".

Example: The simple XML Code with error

<?xml version="1.0" encoding="utf-8" ?>
<country>
    <text>India</Text>  
    <value>01</value>
</country>

OUTPUT

xml_vdtor_error.gif

In this example Just add the DOCTYPE declaration in XML.

 

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE country [
  <!ELEMENT country (text, value)>
  <!ELEMENT text     (#PCDATA)>
  <!ELEMENT value    (#PCDATA)>
  ]>
  <country>
    <text>India</text>
    <value>01</value>
  </country>
 

OUTPUT

xml_output.gif


Further Readings
You may also want to read these related articles :

Regular Expression Validator
Ask Your Question 
XML more article

© 2020 DotNetHeaven. All rights reserved.