0
votes

I am attempting to select a node based on a value in an element in an xml file that contains a namespace.

I am using Automation Anywhere's Get XML Node command that limits me to using a single line XPath statement.

This is the sample xml file

<IMPORT xmlns="urn:Import">
    <STUFF>
        <STUFF_TYPE>
            <STUFF_TYPE_KEY>1</STUFF_TYPE_KEY>
        </STUFF_TYPE>
        <WALMART>
            <STORE>
                <STORE_ID TYPE="SC" ID="SC-12345">WM000001</STORE_ID>
                <STORE_STATUS>O</STORE_STATUS>
            </STORE>
        </WALMART> 
    </STUFF>
</IMPORT>

I would like to select the STORE_STATUS value where STORE_ID = WM000001

Right now, it is not finding the node.

2

2 Answers

0
votes

You can use a namespace agnostic expression like

//*[local-name() = 'STORE']/*[local-name() = 'STORE_ID' and text() = 'WM000001']/../*[local-name() = 'STORE_STATUS']

This selects the STORE_STATUS element from all STORE elements with STORE_ID children which have the value WM000001. If you only want the value, add a /text() to the end of the expression.

0
votes

This ended up working:

//*[local-name() = 'STORE']/*[local-name() = 'STORE_ID' and text() = 'WM000001']/following-sibling::*[local-name() = 'STORE_STATUS']