Hi there -
I'm totally new to xml and am trying to get the most basic functions to work correctly! I'm sorry if this is a dupe, but I didn't see anything here dumbed down enough to my level! :-)
So, I'm pretty close, but no cigar. All I want to do is pull an XML value into a dynamic text field and something has gone awry!
I am able to get the xml to load. I am also able to pull the xml tags and value into the dynamic text field, but I cannot figure out how to pull only the value.
Here is the line of code that should pull the xml value into the text field:
Code:
phoneBook.text = contactXML.childNodes[1].childNodes[0].childNodes[0];
I thought that this would return a last name (such as Jones). However, I get: <last>Jones</last>
If I do this:
Code:
phoneBook.text = contactXML.childNodes[1].childNodes[0].childNodes[0].nodeValue;
it returns Null
One thing I noticed is that when I run a nodeType, it returns a 1. textNodes are 3's, but I'm not sure this is the issue. I think my XML is okay... Here's an excerpt taken from the larger doc:
Code:
<?xml version = "1.0" encoding = "UTF-8"?>
<phoneBook>
<contact id="1">
<nameFirst>John</nameFirst>
<nameLast>Doe</nameLast>
<address> 123 JohnDOE Lane</address>
<phone>123 456</phone>
</contact>
</phoneBook>
What am I missing here?
Thanks for your help!