|
////////////////////////////////////////////////////////////////////////
XML File
////////////////////////////////////////////////////////////////////////
<Campaigns>
<Campaign ScriptID="1111111" SeqNo="1">
<ID>C38BA51F-5D86-4395-92B5-010F7A64D999</ID>
<Url>http://www.test1.com</Url>
</Campaign>
<Campaign ScriptID="1111111" SeqNo="2">
<ID>4395-92B5-010F7A64D999</ID>
<Url>http://www.test2.com</Url>
</Campaign>
<Campaign ScriptID="1111111" SeqNo="3">
<ID>C38BA51F-010F7A64D999</ID>
<Url>http://www.test3.com</Url>
</Campaign>
<Campaign ScriptID="1111111" SeqNo="4">
<ID>010F7A64D999</ID>
<Url>http://www.test4.com</Url>
</Campaign>
</Campaigns>
////////////////////////////////////////////////////////////////////////
CODE to parse the XML selected nodes
////////////////////////////////////////////////////////////////////////
var ScriptID = '921924826';
var random_num = 0;
while(random_num == 0)
{
random_num = parseInt((Math.round(Math.random() *4)));
}
x=xmlDoc.getElementsByTagName
('Campaign[@ScriptID = \'' + ScriptID + '\' and @SeqNo = \'' + random_num + '\']');
alert('x.length : ' + x.length);
campaignID = x[0].childNodes[0].childNodes[0].nodeValue;
linkURL = x[0].childNodes[1].childNodes[0].nodeValue;
alert('ID : ' + campaignID + ' Url :' + linkURL);
////////////////////////////////////////////////////////////////////////
Problem
////////////////////////////////////////////////////////////////////////
This code is parsing the above XML file perfectly in IE , but failed in
firefox(2.0.0.12).
It shows the x.length = 0 , why?
May be there is reason of XPath with attributes (ScriptID , SeqNo).
If any idea then please share it.
|