Well-Formed XML
For an XML document to be considered valid, it must satisfy the following restrictions:
The document must have only one top-level element. This element is called the root element.
Every element must have both a start and an end tag.
All attributes must have values, and those values must be quoted.
Elements must not overlap. You cannot use
<a><b></a></b>
, because the ending</a>
tag comes before</b>
.You must convert &, <, and > to their entity equivalents. You can use
htmlentities( )
to solve this.
When a document meets these rules, itâs valid, or well-formed, XML.
Get Upgrading to PHP 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.