cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Thingworx is not handling XML from REST Service correctly.

vranganathan
12-Amethyst

Thingworx is not handling XML from REST Service correctly.

When I return my XML (output of as String from Resources["ContentLoaderFunctions"].GetXML(params);),

It sees only the top level node nothing below it.

I used to GetText and returning that as String which shows what I expect.

I added some debug statment and tried to get them as XML and Text. The following are the outputs.

// result: XML
var xmlPage = Resources["ContentLoaderFunctions"].GetXML(params);
// result: STRING
var txtPage = Resources["ContentLoaderFunctions"].GetText(params);
logger.debug(xmlPage);
logger.debug(txtPage);

xmlPage returns only my top node name.

txtPage returns the entire XML as expected.

If I parse txtPage as XML, I see undefined variable when I assign the values to datashape. In case of XML, it is not going through my for loop as there is no content inside it. The intent is read the XML file and populate datashape.

I would appreciate your help.

Thanks,

Varathan

2 REPLIES 2

i think i have a quite similar problem, whith only the first top node when displaying the XML page.

Did you find a way to fix it ?



e.g. xml data = <data><system attr1="value1"/></data>

you can retrieve the value of attr1 using :

var xmlPage = Resources["ContentLoaderFunctions"].GetXML(params);

var attr_val = xmlPage.system.@attr1

Hope it helps

Announcements


Top Tags