XML XPATH Query sibling value with multiple sibling attributes -
given following xml, wanting build xpath query me text of body node contains html
<documents> <document> <items> <item name='form'> procedure </item> <item name='body'> <![cdata[<p>arbitrary html</p>]]> </item> </items> </document> <document> <items> <item name='form'> process </item> <item name='body'> arbitrary value </item> </items> </document> </documents> i able close, missing something. (this may not best way there, way have been able close)
//document/items/item[@name='form'][text()='procedure']/../item[@name='body'] results in cdata wrapped content, lost how select inner text.
//document/items/item[@name='form'][text()='procedure']/../item[@name='body']/text() is yielding empty string
use xpath expected results:-
//document[items/item[@name='form']/text()='procedure']/items/item[@name='body']/text() result:
<p>arbitrary html</p> updated:
i got actual issue on xml.
the value of form node contains spaces, causing issue.
to solve issue, use new xpath normalize-space()
//document[normalize-space(items/item[@name='form']/text())='procedure']/items/item[@name='body']/text() result:
<p>arbitrary html</p>
Comments
Post a Comment