Loading XML in Other
Browsers
- Loading an XML Document
- Loading an XML String
Loading an XML Document
The following JavaScript fragment loads an XML document
("note.xml") into the parser:
var xmlDoc=document.
implementation.createDocument("","", null);
xmlDoc.async="false";
xml Doc. load("note.xml");
In the script above:
- Line 1 - creates an empty XML document object
- Line 2 - turns off asynchronous loading, to ensure that the parser is not execution until the document is fully loaded
- Line 3 - tells the parser to load an XML document called "note.xml"
Loading an XML String
The following JavaScript fragment loads a string called txt
into the parser:
var parser=new DOMParser(); var
doc=parser.parseFromString(txt,"text/xml");
In the script above:
- Line 1 - creates an empty XML document object
- Line 2 - tells the parser to load a string called txt