Skip to main content
1-Visitor
November 3, 2015
Solved

Problem with XML (parsing)

  • November 3, 2015
  • 1 reply
  • 3026 views

Hi guys,

I have problem with parsing the XML get response.

I have tried every approach which I could find. (here or anywhere else).

It drives me crazy because it is a very simple XML. Here it is.

<?xml version="1.0" encoding="utf-8"?>

<LL control="dev/sps/io/Power/state" value="5.07kW" Code="200"/>

I am getting the result with GetXML (LoadXML works the same), but when I am trying parse the Value out of it, it always returns empty (as none). I am accessing the value with resultXml.LL.@value. (.@code, .@control -- all empty). I have tried to iterate and push the results  into the array - nothing. XML is not using namespaces. If I use warn.log it is also empty. I have tried different Base types. Nothing. Strange is that if I set the result to XML and use var result = Resources[]..... I can see the result while running service through the REST API, but if I try logger.warn(xmlResult) it is also blank.

Best answer by paic

Maybe try resultXml.@value

else resultXml.*::LL.@value maybe resultXml.*::LL.*::@value

Sorry if these don't work, the second one is a basic way of trying to escape Name spaces.

1 reply

paic1-VisitorAnswer
1-Visitor
November 3, 2015

Maybe try resultXml.@value

else resultXml.*::LL.@value maybe resultXml.*::LL.*::@value

Sorry if these don't work, the second one is a basic way of trying to escape Name spaces.

tcoufal1-VisitorAuthor
1-Visitor
November 3, 2015

Hi Pai,

the first one did it

And I thought I have tried that one.

Still dont get why it cannot be accessed with "LL" (perhaps its a parent or root node?)

Thank you though.

1-Visitor
November 3, 2015

Correct root node is skipped.