NYCPHP Meetup

NYPHP.org

[nycphp-talk] XPath Assistance

Joseph Crawford codebowl at gmail.com
Fri Oct 14 07:55:35 EDT 2011


Hello Everyone,

I have recently been working with XPath and have a document setup like the code below

<div id='content>
<h3>Content</h3>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
<h3>Content</h3>
<div class='log-entry'>Content</div>
<h3>Content</h3>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
<div class='log-entry'>Content</div>
</div>

What I am attempting to accomplish is grab each H3 element and then grab every log-entry class element that immediately follows the H3
up until the point when another H3 is found.  Basically the same results as JQuery's .nextUntil() function.

Is this possible to do in XPath?  Would I have to work up some PHP code to replicate JQuery's .nextUntil() function?

Any assistance would be appreciated.

Here is my example code: http://codepad.viper-7.com/BOz0Ak
Note that my current xpath query fetches ALL log-entry's and not solely the siblings of the current h3 tag

Thanks,
Joseph Crawford


More information about the talk mailing list