Accessing XML nodes using XPath -


<attributes>   <attribute name="mail zone" property="alerts.p45" type="">     <value>mailzone</value>   </attribute>   <attribute name="employee name" property="acm_alert_custom_attributes.cs11" type="">     <value>employeename</value>   </attribute>   <attribute name="manager name" property="alerts.p23" type="">     <value><managername></value>   </attribute> 

how can select node <value> based on attribute "name" of above xml using xpath?

let's wanted select value element child of attribute name "employee name".

the xpath expression following:

/attributes/attribute[@name="employee name"]/value 

in xsl can use this:

<xsl:value-of select="/attributes/attribute[@name='employee name']/value"/> 

it's built following way. first want select value attribute, parent attribute element, parent root (i'm assuming) attributes. / operator indicates parent-child relationship between elements. expression select all value elements following:

/attributes/attribute/value 

with base, want filter result other attribute. in case, want filter name attribute of attribute element (your choice of names might make things hard follow). filtering done [] clauses on elements want filter by. in case that's attribute element:

/attributes/attribute[]/value  

now need put in filter. @ symbol indicates attributes of element you're filtering by, followed name of attribute want. compare attribute known value, arrive @ above expression:

/attributes/attribute[@name='filter']/value 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -