Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 10
Name: Muhammad Abrar
Trades: 0
////////////////////////////////////////////////////////////////////////
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
 
 
Register now for full access!
Reply     « Reply to How to get NodesList by Xpath with Attributes Filters
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.34298 seconds with 12 queries