Search code examples
xmlxsltxpathworkday-api

XPath for Descriptor in Node


I'm trying to set properties and confused as to what the xpath would be. For example, one of my properties is

props['SuperiorOrganization'] = parts[0].xpath('/rs:Report_Entry/rs:SuperiorOrganization/Descriptor') 

and I tried using rs:/descriptor with no value.

My xml is returning something like this:

<wd:SuperiorOrganization wd:Descriptor="Name of Supervisory">
<wd:ID wd:type="WID">XXXXXXXXXXXXXXXXXXX</wd:ID>
<wd:ID wd:type="Organization_Reference_ID">XXXXXX</wd:ID>

Solution

  • rs:Descriptor is an attribute and attributes have to be prefixed with an @ in XPath expressions. So a working expression to get the string

    Name of Supervisory

    could be

    /rs:Report_Entry/rs:SuperiorOrganization/@rs:Descriptor
    

    (Assuming that the rs: and the wd: namespaces are interchangeable.)