October 13, 2009

0 Xml Parser in Mozilla Browsers

Plain XML documents are displayed in a tree-like structure in Mozilla (just like IE).

Mozilla also supports parsing of XML data using Javascript. The parsed data can be displayed as HTML.

To create an instance of the XML parser with JavaScript in Mozilla browsers, use the following code:

var xmlDoc=document.Implementation.createDocument("ns", "root", null)

The first parameter, ns, defines the name space used for the XML document. The second parameter, root, is the XML root element in the XML file. The third parameter, null is always null because it is not implemented yet.

The following code loads an existing XML document ("note.xml") into Mozillas' XML parser.

<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("", "",null);
xmlDoc.load("note.xml");
. . .
. . .

</script>

The first line of the script above creates an instance of the XML parser. The second line tells the parser to load an XML document called "note.xml".

0 comments:

Post a Comment

Blogger Themes

 
Powered by Blogger