Reply
How to get NodesList by Xpath with Attributes Filters
Old 03-19-2008, 10:08 AM How to get NodesList by Xpath with Attributes Filters
Novice Talker

Posts: 10
Name: Muhammad Abrar
////////////////////////////////////////////////////////////////////////
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.
AbrarNazeer is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Reply     « Reply to How to get NodesList by Xpath with Attributes Filters
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11355 seconds with 13 queries