I need your help, at first I start on code:
bookmod.xml
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="COOKING">
<insystem>
<t>asdgas</t>
<b>asdgas</b>
</insystem>
<data>
<Data name="title">Everyday Italian</Data>
<Data name="author">Giada De Laurentiis</Data>
<Data name="year">2005</Data>
<Data name="price">30.00</Data>
</data>
</book>
<book category="CHILDREN">
<insystem>
<t>asdgas</t>
<b>asdgas</b>
</insystem>
<data>
<Data name="title">Potter Potter</Data>
<Data name="author">Giada De Laurentiis</Data>
<Data name="year">2003</Data>
<Data name="price">30.00</Data>
</data>
</book>
<book category="WEB">
<insystem>
<t>asdgas</t>
<b>asdgas</b>
</insystem>
<data>
<Data name="title">asdgasd Potter</Data>
<Data name="author">Giada De Laurentiis</Data>
<Data name="year">2005</Data>
<Data name="price">30.00</Data>
</data>
</book>
<book category="WEB">
<insystem>
<t>asdgas</t>
<b>asdgas</b>
</insystem>
<data>
<Data name="title">web book</Data>
<Data name="author">Giada De Laurentiis</Data>
<Data name="year">2005</Data>
<Data name="price">30.00</Data>
</data>
</book>
</bookstore>
index.php
<!DOCTYPE html>
<html>
<body>
<script>
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
try {xhttp.responseType="msxml-document"} catch(err) {} // Helping IE
xhttp.send("");
return xhttp;
}
var x=loadXMLDoc("bookmod.xml");
var xml=x.responseXML;
path="/bookstore/book/data/Data";
// code for IE
if (window.ActiveXObject || xhttp.responseType=="msxml-document")
{
xml.setProperty("SelectionLanguage","XPath");
nodes=xml.selectNodes(path);
for (i=0;i<nodes.length;i++)
{
document.write(nodes[i].childNodes[0].nodeValue);
document.write("<br>");
}
}
// code for Chrome, 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>
In Path I try also : /bookstore/book/data[Data=2005]/Data[@name='year']
and many other...
It basically means that an XML file is quite large and I need to find only those where <data name="year">
== 2005
I tried many ways and generators, but still can not deal with it :(
It would have been nice if you could enter a title and author.
Edit:
<book xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
I do not know why but for it not working
Do you know a method to get around this? when I delete xmlns="..... everything works well but I have it.