How to Validate XML code
With its free and flexible tag system, XML is vulnerable to small problems. As the W3 code standards organization says: "XML errors will stop you." Trying to validate your XML code will help to prevent the intrusion of errors into your program.
Instructions
-
-
1
Create "well-formed" XML. This includes putting opening/closing tags in the proper places, isolating and identifying your root element, and not adding incongruous structures into your element configurations. The W3 calls good XML code "well-formed", calling up images of organic systems, and truly, XML does mimic natural systems in many ways. It helps to think of an XML code as an organism and to think of the correct formation of its parts.
-
2
Validate your XML with a DTD (Document Type Definition). A DTD is a separate file that includes commands for XML syntax. Include a linking statement to the DTD in your XML text.
-
-
3
Validate XML code with an XML schema. The schema was introduced as an alternative to the DTD. The schema is more text-oriented as its code "wraps around" XML elements to provide a legible structure that programmers can look at to make the "well-formed" XML system.
-
4
Use the W3 XML validator. On the W3 site, there is a validating program that can help you fix XML errors. Under "XML tutorial" go to the "XML validator" tag and look for the text box where you can upload your code/url and the program will identify XML errors for you. This program only works for the Internet Explorer browser.
-
5
Check the web. Tips and tricks of other programmers abound on the Internet. Locate relevant code by entering search terms specific to what you are trying to do with XML.
-
1