code_junkie

Validating XML tag by tag

Nov 13th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsd:schema
  3. attributeFormDefault="unqualified"
  4. elementFormDefault="qualified"
  5. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  6. <xsd:element name="Dog">
  7. <xsd:complexType>
  8. <xsd:sequence>
  9. <xsd:element name="Age" type="xsd:int"/>
  10. <xsd:element name="Name" type="xsd:string"/>
  11. </xsd:sequence>
  12. </xsd:complexType>
  13. </xsd:element>
  14. </xsd:schema>
  15.  
  16. <Dog>
  17. <Name>Rex</Name>
  18. <Age>three</Age>
  19. </Dog>
  20.  
  21. 1. The element 'Dog' has invalid child element 'Name'.
  22. 2. The 'Age' element is invalid - The value 'three' is invalid according to its datatype
Add Comment
Please, Sign In to add comment