xPath-XML-Datei mit namespaces mithilfe von Javascript

Ich habe eine TON von Forschung und trotzdem nur Treffer einer Sackgasse 🙁

Hier meine XML-Datei (test.xml):

<bookstore>
  <book genre="autobiography">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <bk:book genre="novel" bk:genre="fiction" 
xmlns:bk="http://purl.org/dc/elements/1.1/">
    <bk:title>The Confidence Man</bk:title>
    <bk:author>
      <bk:first-name>Herman</bk:first-name>
      <bk:last-name>Melville</bk:last-name>
    </bk:author>
    <bk:price>11.99</bk:price>
  </bk:book>
</bookstore>

Heres meine Javascript-Datei:

<html>
<body>
<script type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}


xml=loadXMLDoc("test.xml");
//xml.remove_namespaces;
path="/bookstore/bk:book/bk:title";
//code for IE
if (window.ActiveXObject)
{
var nodes=xml.selectNodes(path);
//var nodes=xmlDoc.getElementsByTagName('bk:title');

for (i=0;i<nodes.length;i++)
  {
  document.write(nodes[i].childNodes[0].nodeValue);
  document.write("<br />");
  }
}
//code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
var result=nodes.iterateNext();

while (result)
  {
  document.write(result.childNodes[0].nodeValue);
  document.write("<br />");
  result=nodes.iterateNext();
  }
}
</script>

</body>
</html>

Ich Schaffe es nicht, den Wert innerhalb der bk-Namespaces-tags 🙁

Ich habe alles versucht, dass //*[name() etc etc, Müll, no-go 🙁

Jede Hilfe wäre sehr geschätzt werden!!!!!!!!!!!!!!!!!!!

Freundlichen GRÜßEN,
Sam Gungormez

Schreibe einen Kommentar