|
February 25, 2002 Validating DOMDocument Upon Request Tips: February 2002
Yehuda Shiran, Ph.D.
|
|
Since you can add and modify nodes to the DOMDocument tree, there must be a way to validate the DOMDocument upon request, and not only upon loading. You can do this in later versions of Internet Explorer with the validate() method. Here is code that loads an XML file, adds an attribute to the root node, and validates the new DOMDocument:
Notice the err error object that holds very useful information. For example, it pinpoints the fact that the new attribute "foo" is not defined in the DTD file and hence is illegal. Try it.
People who read this tip also read these tips: Look for similar tips by subject: |