Forum Discussion

mohneyman's avatar
mohneyman
New Contributor
13 years ago

XPath to select specific child element failing

Hi all,

I'm have issues with trying to select a specific child element in a XML response tree. If I do a Get Data I can get the specific child element but it is referenced by the index number. (ex: User[1]) However, I can't always rely that the order will be the same each time. So I was trying to use standard XPath to specify the element based on one of it's child elements. Here's a example of my result set:

<Users xmlns="urn:dell.com:vis:schema:1.0">
<User isGroup="true" role="none">
<Username>Allowed RODC Password Replication Group</Username>
<SID>S-1-5-21-1751981889-2362576111-3010046495-571</SID>
</User>
<User isGroup="false" role="none">
<Username>amiller</Username>
<FullName>Andy Miller</FullName>
<Email>amiller@MavCustEnv01.com</Email>
<SID>S-1-5-21-1751981889-2362576111-3010046495-1171</SID>
</User>
<User isGroup="false" role="none">
<Username>atannuru</Username>
<FullName>Anil Tannuru</FullName>
<Email>atannuru@MavCustEnv01.com</Email>
<SID>S-1-5-21-1751981889-2362576111-3010046495-1175</SID>
</User>
<User isGroup="false" role="none">
<Username>azacharski</Username>
<FullName>Adam Zacharski</FullName>
<Email>azacharski@MavCustEnv01.com</Email>
<SID>S-1-5-21-1751981889-2362576111-3010046495-1172</SID>
</User>
</Users>

In a subsequent step I reference the response using:
${Get User Info#ResponseAsXml#declare namespace ns1='urn:dell.com:vis:schema:1.0'; //ns1:User[2]}

And this does return the User element for amiller:
<User isGroup="false" role="none">
<Username>amiller</Username>
<FullName>Andy Miller</FullName>
<Email>amiller@MavCustEnv01.com</Email>
<SID>S-1-5-21-1751981889-2362576111-3010046495-1171</SID>
</User>

However, if I try instead to use standard XPathing to get that node:
${Get User Info#ResponseAsXml#declare namespace ns1='urn:dell.com:vis:schema:1.0'; //ns1:User[Username = "amiller"]}

This returns an empty set. Can anyone see any obvious mistake I'm making? Is there a different way to reference the child element name?

Any help would be greatly appreciated!

Thanks,

-Chris
No RepliesBe the first to reply