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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML object

Status
Not open for further replies.

SFiend

Programmer
Jun 4, 2004
39
CZ
hello, I receive via XML.sendAndLoad function this XML data:

Code:
<?xml version="1.0"?>
<telo><nadpis>Ad Net</nadpis><popisek>lfh skahf sjhf kajsh fkajsh fkjhsfjhsakfh a flkjshk jhs fhsk hfkjhs fkjhfk jhskj hkfhklskfkfasf</popisek><odchoziUrl>[URL unfurl="true"]http://www.adnetltd.com</odchoziUrl><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdbf8ea2e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc04a493.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc09ad8e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc0e8f83.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc171594.jpg</urlObrazek></telo>[/URL]

and here is code in flash:
Code:
prijateXML.onLoad = function () {
trace (this.childNodes);
}

and here is trace output:
Code:
,<telo><nadpis>Ad Net</nadpis><popisek>lfh skahf sjhf kajsh fkajsh fkjhsfjhsakfh a flkjshk jhs fhsk hfkjhs fkjhfk jhskj hkfhklskfkfasf</popisek><odchoziUrl>[URL unfurl="true"]http://www.adnetltd.com</odchoziUrl><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdbf8ea2e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc04a493.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc09ad8e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc0e8f83.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc171594.jpg</urlObrazek></telo>,[/URL]

when I want get XML I have to get it from second item in array childNodes like this:
Code:
prijateXML.onLoad = function () {
trace (this.childNodes[1]);
}

and the output is:
Code:
<telo><nadpis>Ad Net</nadpis><popisek>lfh skahf sjhf kajsh fkajsh fkjhsfjhsakfh a flkjshk jhs fhsk hfkjhs fkjhfk jhskj hkfhklskfkfasf</popisek><odchoziUrl>[URL unfurl="true"]http://www.adnetltd.com</odchoziUrl><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdbf8ea2e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc04a493.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc09ad8e.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc0e8f83.jpg</urlObrazek><urlObrazek>http://www.adnetltd.com/obrazky/pic4497cdc171594.jpg</urlObrazek></telo>[/URL]

why it an array with 3 items, 2 of them empty???

Do anybody know the answer?
 
Your XML has one child node, which is <telo>.
Therefore if you do:

[tt]trace(this.childNodes[1]);[/tt]

You should get "undefined", because there is no second child.

What you're looking for is probably:

[tt]trace(this.firstChild.childNodes[1]);[/tt]

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top