- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2018 10:40 AM
I have XML :
var xmlString = "<?xml version='1.0' encoding='UTF-8'?>"+
"<parameters><parameter name='message_header' value='head123'/>"
"<parameter name='message_content1' value='content123'/>"+
"<parameter name='message_content2' value='content456'/></parameters>";
How I can get note value in the script? e.g. get 'message_content2' value 'content456'.
Thanks,
Faye
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2018 07:30 PM
It's more than 2 weeks now, but got some time to look into this. Let try with below code, hope this will help. I was able to print the value in background script.
var xmlString = "<?xml version='1.0' encoding='UTF-8'?>"+
"<parameters>"+
"<parameter name='message_header' value='head123'/>" +
"<parameter name='message_content1' value='content123'/>"+
"<parameter name='message_content2' value='content456'/>" +
"</parameters>";
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var iter = xmlDoc.getNode("//parameters").getChildNodeIterator();
while(iter.hasNext()){
var n = iter.next();
var xmlDoc1 = new XMLDocument2();
xmlDoc1.parseXML(n);
var node = xmlDoc1.getNode("//parameter");
var nodeValue = node.toString().split(' ')[2].split('=')[1].replace(/[^a-zA-Z0-9]/g, "");
gs.print(nodeValue);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2018 07:30 PM
It's more than 2 weeks now, but got some time to look into this. Let try with below code, hope this will help. I was able to print the value in background script.
var xmlString = "<?xml version='1.0' encoding='UTF-8'?>"+
"<parameters>"+
"<parameter name='message_header' value='head123'/>" +
"<parameter name='message_content1' value='content123'/>"+
"<parameter name='message_content2' value='content456'/>" +
"</parameters>";
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var iter = xmlDoc.getNode("//parameters").getChildNodeIterator();
while(iter.hasNext()){
var n = iter.next();
var xmlDoc1 = new XMLDocument2();
xmlDoc1.parseXML(n);
var node = xmlDoc1.getNode("//parameter");
var nodeValue = node.toString().split(' ')[2].split('=')[1].replace(/[^a-zA-Z0-9]/g, "");
gs.print(nodeValue);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 07:25 AM
Thanks Shishir.
It looks great. Thanks a lot!
Faye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 09:32 AM
It's really great workaround.
Thanks,
Rajashekhar Mushke
Community Leader-18
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke