Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I have loaded some XML from an external source and the info I need is listed as an attribute on the xml group node.
How can the script access the XML attributes using the getXML snippet. I have tried accessing it with brackets "group["name"]" with no luck
example XML: <groups>
<
groupname
= "name1">url<
/group>
<
groupname
= "name2">url<
/group>
...
I'm unsure how to access the attribute name using the getXML code. I am able to retrieve the url so I know that part of the code is working.
CODE:
var configXML = Resources["ContentLoaderFunctions"].GetXML(params);
var groups = [];
for each (var group in configXML.groups.group){
groups.push(group);
}
var result = groups.join(",");
Hi Josh,
try
for each (var group in configXML.groups.group) {
groups.push(group.@name)
}
var result = groups.join(",");
if that doesn't work, try group.name but I think .@name is what you need.
Hi Pai Please how can i access the elements (Id, numero-escale ....)
Yup group.@name did it!
Thank you!
Hi Joshua/Pai,
I need one help. I have an URL. Whenever you will hit the URL ,it will generate dynamic XML based upon the User Selection. But problem is , the XML i am getting or getting generated by ThingWorx contains some unwanted filed provided by Thingworx. How can i am write the query so that i can get the correct format of XML. Below i have given one snapshot of generated XML where i need the highlighted tags as an output from the URL. I want to know what kind of service shall i write so that i will get my required output in URL in XML format. I just wanted the highlighted XML tags only.
Thanks & Regards:
kshirod