Do not succeed to get XML attribute from response

Hi,

I try to parse this xml:

<?xml version="1.0" encoding="utf-8"?>
<Response xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Header>
        <MessageID>1</MessageID>
        <Response ResponseCode="Ok">
            <RequestID>1</RequestID>
        </Response>
    </Header>
    <Worker MajorVersion="1" MinorVersion="0" FixVersion="1">
        <WorkerID>77b07aa7-5025-4fc9-8a31-37bd67d80066</WorkerID>
        <AllowedForBarcode>true</AllowedForBarcode>
        <DaysToExpire>-1</DaysToExpire>
    </Worker>
</Response>

I try to get to the
ResponseCode="Ok
from the xml.

I convert the xml to json :
var xmlTree = xml2Json(responseBody);

I can not reach to the xml attribute its under a $ sign - and I can not reach it.

Please help.

Thanks a lot

Hi Lee- I had this same problem, and I think I’ve found the solution! Just put the dollar sign in the command that you are using to reach the attribute. For example, I had a response that looked like the attached image, and I was able to access it with jsonObject.builds.build[0].$.id

I hope this helps you! XMLToJSON

2 Likes

Perfect, thanks for the $ tip :slight_smile: