I had the same problem, but i still testing on netscape/mozilla.
e.g.
inhoud = document.implementation.createDocument("", "inhoud", null);
inhoud.addEventListener("load", documentLoaded, false);
inhoud.load("index.xml");
function documentLoaded()
{
var berichten = inhoud.getElementsByTagName("pagina")[0];
var topic = berichten.getElementsByTagName("bericht")[0];
var zoek = topic.getElementsByTagName("inhoud")[0].firstChild.data;
...
}
(for this xml example)
<?xml version="1.0" encoding="iso-8859-1"?>
<bron>
<pagina>
<bericht>
<inhoud>blah</inhoud>
</bericht>
</pagina>
</bron>
"ptc1" <ptc1@xxxxxxxxxxxxx> schreef in bericht
news:pan.2003.12.09.22.23.25.722329@xxxxxxxxxxxxxxxx
> Could someone provide a very simple example on how
> to do queries on an XML document in Netscape? I have
> some sample code which allegedly works for IE:
>
> ======================================
>
> <script language = "JavaScript">
> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
> xmlDoc.async="false";
> xmlDoc.load("periodic-table.xml" );
>
> document.write("<p>root node of the document is: ");
> var root = xmlDoc.documentElement;
> document.write("<em>", root.nodeName, "</em></p>");
>
> document.write("<p>first child of root node is: ");
> var curNode = root.firstChild;
> document.write("<em>", curNode.nodeName, "</em></p>");
>
> document.write("<p>first child of this node is: ");
> curNode = curNode.firstChild;
> document.write("<em>", curNode.nodeName, "</em></p>");
>
> document.write("<p>next sibling of this node is: ");
> var nextSib = curNode.nextSibling;
> document.write("<em>", nextSib.nodeName, "</em></p>");
>
> document.write("<p>parent node of ");
> document.write("<em>", nextSib.nodeName, "</em> is: ");
> document.write("<em>", nextSib.parentNode.nodeName, "</em></p>");
>
> ========================================
>
> But this wont work in Netscape, as I get 'ActiveXObject not defined'
> errors. I've also tried GeckoActiveXObject, but I get a similar error.
>
> How would I implement the above code so it works in Netscape 7.1.
> All I want to do is query a local XML file.
>
> thanks in advance for any help,
> -ptc1
|