Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting value of XML 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
Here is my xml (news.xml)
<?xml version=&quot;1.0&quot;?>
<news>
<newsitem>
<headline>head line 0</headline>
<newstext>this is the text for newsitem
0</newstext>
</newsitem>
<newsitem>
<headline>head line 1</headline>
<newstext>this is the text for newsitem
1</newstext>
</newsitem>
</news>

Here is my AS:
function myOnLoad() {
//trace(myXML);
trace(myXML.firstChild.firstChild.firstChild.nodeValue);
}

if (myXML.loaded) {
if (myXML.status==0) {
myXML.ignoreWhite;
myXML.onLoad=myOnLoad();

_root.stop();
} else {
myBox.text=&quot;notloaded&quot;;
_root.gotoAndPlay(2);
}
} else {
gotoAndPlay(2);
}

I know the xml is getting loaded as trace(myXML) works fine, but
trace(myXML.firstChild.firstChild.firstChild.nodeValue);
produces undefined when my thinking is that it should produce head
line 0

what am I doing wrong?
 
You need an extra 'firstchild', this gets you there as a test:

function myOnLoad() {
trace(myXML.firstChild.firstChild.firstChild.firstChild.nodeValue);
}
myXml = new XML();
myXML.onLoad = myOnLoad;
myXML.load('news.xml');
myXML.ignoreWhite = true;
 
actually, know what the problem is: the white space ???? I have the ignoreWhite in there:

if (myXML.status==0) {
myXML.ignoreWhite;
myXML.onLoad=myOnLoad();

_root.stop();
}

but for some reason it is not getting ignored, because when I took all the whitespace out- it worked fine...
 
shouldn't it be:

myXML.ignoreWhite = true;

NOT just

myXML.ignoreWhite;

?
 
I think (may be wrong) with MX you can just say myXML.ignoreWhite; whereas with 5 you did need to set it to true
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top