Don't go into element tree in xpath

pokplay

New Member
I have some XML that looks like\[code\]<page id="1"> <subpages> <page id="2"> <subpages> <page id="3"> </subpages> </page> <page id="4"></page> <page id="5"></page> </subpages></page>\[/code\]What I'm trying to do is pull out the top level \[code\]<page>\[/code\] in the top \[code\]<subpages>\[/code\] tag meaning I'm trying to pull out pages 2, 4, and 5, but not 3.Right now I'm doing \[code\]//subpages[1]/page\[/code\] but this gets all the pages inside of the first subpages tag. Is there a way to do this?I'm able to do this in jQuery with\[code\]var c = $(data).find("subpages").first();$(c).children("page").each(function() {});\[/code\]If I can't get a proper xpath to work, is there a way to make Nokogiri behave like jQuery does?
 
Back
Top