[Wtr-general] General XPath Question

John Castellucci johnc at testdev.net
Mon May 22 15:21:03 EDT 2006


I've been crawling through xpath for the last couple of weeks, but I've been
unable to solve a real basic problem I am having locating desired objects.  
 
As a background, the application I am automating makes extensive use of
AJAX, Javascript, Dojo and DWR, so the DOM gets complex.
 
Sample XML:
 
<DIV class=A>
   <DIV class=B>
   </DIV>
   <DIV class=B>
   </DIV>
<DIV>
<DIV class=A>
   <DIV class=B>
   </DIV>
   <DIV class=B>
   </DIV>
 </DIV>
 
Now, what I am trying to do is directly access each 'B' Div - i.e. :
 
The first B in the first A
The second B in the first A
The first B in the second A
The second B in the second A
ad infinitum.
 
The XML isn't as simple as the above - since it's dynamically updated via
AJAX- based on context, there are potentially an unknown amount of elements
before, after or inside the above tags.  So, stuff like:
 
/DIV[1]/DIV[1]
 
won't work for me.   Also, while the below looks like it should work (and
does on basic XML), it returns a set of *all* B elements under an A from the
IE DOM:
 
//DIV[@class='A'][1]/DIV[@class='B'][1]
 
Any tips on cracking this nut?
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060522/d18aa9bf/attachment.html 


More information about the Wtr-general mailing list