PHP Xpath following-siblings -
I am trying to use xpath to get the content of a table.
The table looks like this
& lt; Div & gt; & Lt; Table & gt; & Lt; Tr class = "tableheader" & gt; & Lt; TD & gt; Stuff & lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "indent1" & gt; & Lt; TD & gt; Content & lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "indent1" & gt; & Lt; TD & gt; Content & lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "tableheader" & gt; & Lt; TD & gt; Stuff & lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "indent1" & gt; & Lt; TD & gt; Content & lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "indent1" & gt; & Lt; TD & gt; Content & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Div & gt;
I am trying to drag the value of all tr [@ class = 'indent1'] between table headings
This is what I've done so far :
$ element = $ xPath-> Query ("div / table / tbody / tr [@ class = 'tableheader']"); ($ I = 0; $ i & lt; $ element- & gt; Length; $ i ++) {Print "Node:". $ Element- & gt; Items ($ i) - & gt; Node vela "\ N"; $ Brother-Sister = $ xPath- & gt; Query ("low-sibling :: tr [@ class = 'indent 1']", $ element-> item ($ i)); Exotic ($ Brothers as Brothers $) {Print "\\ Sibling:". $ Sibling-> nodeValue "\ N"; }}
Expected output is
node: stuff sibling: material sibling: content node: stuff siding: content siphoning: content
s
Instead it is printing all tr class = "indent1s" for each one
thanks
Edit:
Okay maybe it helps you. Just to get to each brother and check the attributes with PHP:
foreach ($ $ $ as brother siblings) {if (! Is_a_ (other ($ sailing-> Properties) & amp; amp; amp; Features-> GetNamedItem ('Class') -> Node Vela == 'Indent 1') {Break; } Print "\ tSigning:". $ Sibling-> nodeValue "\ N"; }
What is your goal in general? If you want to print the nodes, processing with the structure will be more suitable and easier (php with SX).
Or maybe I can not help you with that.
Comments
Post a Comment