Well Formed XML
An XML document is called well-formed if it satisfies certain rules, specified by the W3C.
These rules are:
- A well-formed XML document must have a corresponding end tag for all of its start tags.
- Nesting of elements within each other in an XML document must be proper. For example, <tutorial><topic>XML</topic></tutorial> is a correct way of nesting but <tutorial><topic>XML</tutorial></topic> is not.
- In each element two attributes must not have the same value. For example, <tutorial id="001"><topic>XML</topic></tutorial> is right,but <tutorial id="001" id="w3r"><topic>XML</topic></tutorial> is incorrect.
- Markup characters must be properly specified. For example, <tutorial id="001"><topic>XML</topic></tutorial> is right, not <tutorial id="001" id="w3r"><topic>XML</topic></tutorial>.
- An XML document can contain only one root element. So, the root element of an xml document is an element which is present only once in an xml document and it does not appear as a child element within any other element.
Example of a Valid XML document
<?xml version="1.0" ?> <w3resource> <design> html xhtml css svg xml </design> <programming> php mysql </programming> </w3resource>
Example of an invalid XML
<?xml version="1.0" ?> <w3resource> <design> <programming> html xhtml css svg xml </Design> php mysql </programming> </w3resource>
To check whether an XML document is well-formed or not, you have to use an XML parser.
An XML parser is a Software Application, which introspects an XML document and stores the resulting output in memory. If an XML document is parsed by an XML parser and some irregularities are found, it generates some errors and it is then denoted as an XML file , which is not a well-formed XML document.
Well-formed XML is an XML document which follows some rules specified by W3C.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework