xml - XPath to find elements that have no other elements referencing them -
xml - XPath to find elements that have no other elements referencing them -
given next xml document…
class="lang-xml prettyprint-override"><r> <e id="a" /> <e id="b" /> <e id="c" /> <x ref="#b" /> </r> …how can write xpath 1.0 look finds <e> elements not have <x> element referencing them? in example, result should #a , #c.
based on this question tried //e[ not(//x[@ref=concat("#",@id)]) ], not omit referenced element:
# ruby code using nokogiri puts doc.xpath( '//e[ not(//x[@ref=concat("#",@id)]) ]' ) #=> <e id="a"/> #=> <e id="b"/> #=> <e id="c"/> is there way utilize attribute in found set farther query values of other attributes in other elements?
from xml
<r> <e id="a" /> <e id="b" /> <e id="c" /> <x ref="#b" /> </r> this xpath
//e[ not(//x/@ref=concat("#",@id)) ] will select
<e id="a"/> <e id="c"/> as requested.
xml xpath nokogiri
Comments
Post a Comment