XML DOM Browser Differences
Browser DOM parsing the difference
All modern browsers support the W3C DOM specification.
However, there are differences between browsers. One important difference is:
- Handling blanks and line breaks
DOM - blank and newline
XML often contain newline or whitespace characters between the nodes. This is a simple editor (such as Notepad) to edit the document's often the case.
The following example (from the Notepad editor) between each row contains CR / LF (line feed), before each child node contains two spaces:
<book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
Internet Explorer will not be empty as blank or wrap text nodes, while other browsers.
The following code fragment shows (books.xml a) How many child nodes the root element:
Examples
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.documentElement.childNodes;
document.write("Number of child nodes: " + x.length);
x=xmlDoc.documentElement.childNodes;
document.write("Number of child nodes: " + x.length);
try it"
Examples explain:
- Use loadXMLDoc () to " the Books.xml " into xmlDoc
- Getting child nodes of the root element
- Output number of child nodes. The result depends on the browser you are using. IE browser will output 4 (4 remind child nodes), while other browsers will output 9 (9 remind child nodes).