Getting Xpath node values in nested XML -
my xml structure like,
<items> <item> <brand> <id> 3 </id> </brand> <product> <producttype>type 1</producttype> </product> </item> <item> <brand> <id> 4 </id> </brand> <product> <producttype>type 2</producttype> </product> </item> </items>
i need product type value if user provides brand id. eg, if user enters brand id 3, need return product type type 1
i tried xpath expression
/items/item/brand[id = 3]/product/producttype
but not work. correct xpath expression.
you have simple nesting problem since brand
sibling product
, not anscestor xpath query implies.
simply change to:
/items/item[brand/id = 3]/product/producttype
result:
element='<producttype>type 1</producttype>'
Comments
Post a Comment