How to get elements by tag name in an XML?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 02:45 PM
Hi
I have the following piece of XML and trying to parse it. I am using a client callable script include.
I need to get all the elements that are tagged with "<name>".
<l:cellphone>
<name>data_type</name>
<value>1X</value>
</l:cellphone>
<l:cellphone>
<name>sms</name>
<value>none</value>
</l:cellphone>
<l:cellphone>
<name>voice</name>
<value>none</value>
</l:cellphone>
<l:cellphone>
<name>wifi</name>
<value>wifi.net</value>
</l:cellphone>
I have tried the following 'getElementByTagName' but the script doesn't even run when that line is in. I have parsed other elements with getNodeText and that works but will only get the first element that is tagged with 'name'.
x = xmlDoc.getElementsByTagName("name")[0];// when this is in script stop running at that line and no getting anything on logs.
Thanks for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 07:17 PM
Berny
My code stops in this line var reg = new SNC.Regex("/<name>([(.*)^[^<]]+)/");
I am using a script include ajax... I was checking whether the regex can be used in client callable script include.