NavekRednam
Technical User
I'm trying to build a piece of Javascript that will display a series of tables by pulling data from a single xml file.
I currently have this piece of code.
and so on and so on, until the table is completed.
This works fine in IE and Firefox.
But when I add an xpath expression to the following line, I get nothing from Firefox.
which should check this xml file:
and create a list of businesses that have locations in the nw, which it does in IE; but Firefox refuses to play ball.
Can someone point me in the right direction to where I can get some information on fixing this?
I currently have this piece of code.
Code:
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("books.xml");
var x=xmlDoc.getElementsByTagName("company");
document.write("<table border='1'>");
document.write("<thead><tr><th id='providername' abbr='provider'>Provider</th><th id='contactname' abbr='name'>Contact</th><th id='telephone' abbr='tel'>Tel No</th><th id='emailaddress' abbr='email'>Email</th><th id='websiteaddress' abbr='web'>Website</th></tr></thead><tbody>")
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("provider")[0].childNodes[0].nodeValue);
document.write("</td>");
and so on and so on, until the table is completed.
This works fine in IE and Firefox.
But when I add an xpath expression to the following line, I get nothing from Firefox.
Code:
var x=xmlDoc.getElementsByTagName( "company[location/nw='1']" );
which should check this xml file:
Code:
<list>
<company>
<provider>Company</provider>
<contact>Contact</contact>
<telno>123456789</telno>
<email>blah.d@blahblah.co.zk</email>
<website>[URL unfurl="true"]www.company.co.uk</website>[/URL]
<location><nw>1</nw><sw>0</sw></location>
</company>
<company>
<provider>CompanyII</provider>
<contact>Tcatnoc</contact>
<telno>987654321</telno>
<email>tcat@noc.coz</email>
<website>[URL unfurl="true"]www.IIcompany.coz</website>[/URL]
<location><nw>0</nw><sw>1</sw></location>
</company>
</list>
and create a list of businesses that have locations in the nw, which it does in IE; but Firefox refuses to play ball.
Can someone point me in the right direction to where I can get some information on fixing this?