Each and every XML document should be validated.Each XML document should have proper syntax.XML document is said to “Well Formed XML Document” if it has proper syntax.
Some XML Syntax Rules –
Following are some syntax rules which must be satisfied in order to make “Well Formed XML Document – ”
|Rule No 1 :||XML Document must have Single Root Element|
|Rule No 2 :||XML Elements must have a Closing Tag|
|Rule No 3 :||XML Tags are Case Sensitive|
|Rule No 4 :||XML Elements must be properly nested|
|Rule No 5 :||XML Attribute Value must be quoted|
How to check whether XML is valid or not
There are many online tools which can check whether XML document is valid or not. We can manually check for validity or we can use online tool to check validity.
1. W3C Markup Validation Service
This validator checks the markup validity of Web documents in HTML, XHTML, SMIL, MathML, etc. [Link : w3c Validation Service]
2. XML Validation
Visit http://www.xmlvalidation.com/ and just copy paste your xml into the textbox. It will tell you whether xml is valid or not
Example of Valid XML :
<Email> <to>email@example.com</to> <from>firstname.lastname@example.org</from> <title>Sample Email</title> <message>This is Sample Email Message ....</message> </Email>