Validating an XML file with schema (XSD)

Source: Internet
Author: User

If XML is a database, then XSD is the structure of the database. Thus, XSD is so important that without it, how do we declare and validate the format and legality of the XML data file we need? That's not an impossible task, if you validate the XML data file as a normal text file.

I use the following example to explain how to define an XSD and how to use it to validate

1. First look at our data files

<?xml version= "1.0" encoding= "Utf-8"?> <Order> <OrderID>10248</OrderID> <OrderDate> 2009-01-01</orderdate> <Details> <OrderItem> <ItemNumber>1</ItemNumber> <product id>1</productid> <Quantity>2</Quantity> <UnitPrice>20</UnitPrice> </orderitem > <OrderItem> <ItemNumber>1</ItemNumber> <ProductID>1</ProductID> <quantity >2</Quantity> <UnitPrice>20</UnitPrice> </OrderItem> <OrderItem> <itemnumber >1</ItemNumber> <ProductID>1</ProductID> <Quantity>2</Quantity> <unitprice&gt ;20</unitprice> </OrderItem> <OrderItem> <ItemNumber>1</ItemNumber> <productid& gt;1</productid> <Quantity>2</Quantity> <UnitPrice>20</UnitPrice> </orderitem&gt
 ; </Details> </order&Gt 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.