I have loaded an XML document into the JavaScript DOM using the following (imaginary XML doc for sake of example):
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>9.90</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>
function importXML()
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load("..\ASPX\myXmlDoc.xml");
}
I now want to get all the elements where price is more than £10. Presumbly it is:
/catalog/cd[price=10.90]
Firstly how do I actually implement this using JavaScript and secondly I assume it is easy from this point to use the information i.e. Artist, Title and Price within html tags such as Img, Alt tags etc?
Also any advice for how to make sure the XML doc has loaded before trying to proceed?
Thanks in advance,
Chris
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>9.90</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>
function importXML()
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load("..\ASPX\myXmlDoc.xml");
}
I now want to get all the elements where price is more than £10. Presumbly it is:
/catalog/cd[price=10.90]
Firstly how do I actually implement this using JavaScript and secondly I assume it is easy from this point to use the information i.e. Artist, Title and Price within html tags such as Img, Alt tags etc?
Also any advice for how to make sure the XML doc has loaded before trying to proceed?
Thanks in advance,
Chris