<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 I select the node <value> based on the attribute “name” of the above XML using XPath?
Let’s say you wanted to select the
valueelement that is a child of theattributewhose name is “Employee Name”.The XPath expression for that is the following:
In XSL you can use it like this:
It’s built up the following way. First you want to select a
valueattribute, whose parent is anattributeelement, whose parent is the root (I’m assuming)attributes. The/operator indicates the parent-child relationship between elements. So an expression to select allvalueelements would be the following:With that as a base, you want to filter the result by some other attribute. In this case, you want to filter by the
nameattribute of theattributeelement (your choice of names might make things hard to follow). Filtering is done with[]clauses on the elements you want to filter by. In your case that’s theattributeelement:Now you need to put something in the filter. The
@symbol indicates attributes of the element you’re filtering by, followed by the name of the attribute you want. Then you compare the attribute to some known value, to arrive at the above expression: