returning two XML nodes at once

wayslerfery

New Member
I am trying to obtain a list of \[code\]qux\[/code\] attributes of siblings with a certain attribute, in this case \[code\]x\[/code\] in attribute \[code\]foo\[/code\] and \[code\]y\[/code\] in attribute \[code\]foo\[/code\] of it's sibling.\[code\]//node[@foo="x" and following-sibling::node[@foo="y"]]/@qux | //node[@foo="y" and preceding-sibling::node[@foo="x"]]/@qux\[/code\]This creates a list, but is the same as running both parts separately and adding them together, except for the order. I need a list of both \[code\]qux\[/code\] next to eachother, so a list of two \[code\]qux\[/code\] elements per row, obviously where the siblings match up.Can this be done in xpath, and if so, how? If not, would xquery do the job?edit: sample file and output:\[code\]<database> <ds version="1"> <node> <node foo="x" qux="hello"/> <node foo="y" qux="world"/> </node> </ds> <ds version="1"> <node> <node> <node foo="y" qux="another"/> <node foo="x" qux="sentence"/> <node foo="z" qux="irrelevant"/> </node> </node> </ds> <ds version="1"> <node> <node foo="y" qux="not"/> <node foo="z" qux="returned"/> </node> </ds></database>\[/code\]Note that the depth of the node I'm interested in isn't known, so (I think) usage of //node is necessary.A query should return:\[code\]hello worldanother sentence\[/code\]
 
Back
Top