I have a XML file which I’m loading in via jQuery, once the XML has loaded I read through the XML getting the values out. The problem I’m having is that the XML has a element called VAL, within that there is a child element also called VAL. So when I use:
var val = $(loadedElements[i]).find('val').text();
console.log("val = ", val);
I get all the val elements as one string, not separated as a parent and child.
Here is an example of the XML I’m working with:
<e>
<name>myElement</name>
<type>TEXT</type>
<val>text to display</val>
<acts>
<act>
<type>CLICK</type>
<val>http://www.example.com</val>
</act>
</acts>
</e>
In this example XML when I output the val using console.log("val = ", val); I see:
val = ‘text to display http://www.example.com‘.
How can I separate out the two VAL elements?
Thanks
Stephen
Try this, should get you on you the right track:
or this:
FIDDLE