After creating an XML document from scratch I always check if it is well-formed. This means it must adhere to a number of rules, including the following:
- Every start-tag must have a matching end-tag.
- Elements may nest, but may not overlap.
- There must be exactly one root element.
- Attribute values must be quoted.
- An element may not have two attributes with the same name.
This is not an exhaustive list and I do not mean to explain all the rules. There are many, many ways a document can be malformed. But if you need to determine if and XML document is well-formed there is a linux command for doing that: xmlwf
$xmlwf test.xml
If there is no output, the document is well-formed. If it is not, the output will show you where the problem is:
$ xmlwf test.xml
test.xml:4:38: mismatched tag
For more info man xmlwf
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>