An XML schema defines the structure of an XML document. Validating an XML document against an XML schema ensures that the XML document adheres to the rules defined in the schema. This is useful when you need to ensure that the XML document is in a specific format before you can process it.
This tool allows you to validate XML against XML Schema (XSD).
XML Schema (XSD)
1
<?xml version = "1.0" encoding = "utf-8" ?> 2
<xs:schema attributeFormDefault = "unqualified" elementFormDefault = "qualified" targetNamespace = "http://example.org/books" xmlns:xs = "http://www.w3.org/2001/XMLSchema" > 3
<xs:element name = "bookstore" > 6
<xs:element maxOccurs = "unbounded" name = "book" > 9
<xs:element name = "title" type = "xs:string" /> 10
<xs:element name = "author" > 13
<xs:element minOccurs = "0" name = "name" type = "xs:string" /> 14
<xs:element minOccurs = "0" name = "first-name" type = "xs:string" /> 15
<xs:element minOccurs = "0" name = "last-name" type = "xs:string" /> 19
<xs:element name = "price" type = "xs:decimal" /> 21
<xs:attribute name = "genre" type = "xs:string" use = "required" /> 22
<xs:attribute name = "publicationdate" type = "xs:date" use = "required" /> 23
<xs:attribute name = "ISBN" type = "xs:string" use = "required" /> The XML Schema (XSD) to validate the XML document against.
XML instance
1
<?xml version = "1.0" encoding = "utf-8" ?> 2
<bookstore xmlns = "http://example.org/books" > 3
<book genre = "autobiography" publicationdate = "1981-03-22" ISBN = "1-861003-11-0" > 4
<title> The Autobiography of Benjamin Franklin </title> 6
<first-name> Benjamin </first-name> 7
<last-name> Franklin </last-name> 11
<book genre = "novel" publicationdate = "1967-11-17" ISBN = "0-201-63361-2" > 12
<title> The Confidence Man </title> 14
<first-name> Herman </first-name> 15
<last-name> Melville </last-name> 19
<book genre = "philosophy" publicationdate = "1991-02-15" ISBN = "1-861001-57-6" > 20
<title> The Gorgias </title> The XML document to validate against the XML Schema (XSD).