Posts Tagged ‘DOMDocument’

DOMDocument whitespace text nodes

Monday, March 31st, 2008

The DOMDocument is a convenient way of manipulating an XML file. One issue I ran into was the fact that when loading an XML file, DOMDocument treats the tabs and spaces which make the XML readable as empty text nodes. This presents a problem when you try and traverse the DOM by using attributes like firstChild and nextChild. For example:

Here is the XML file, “example.xml”:

    Value

(more…)