PDA

View Full Version : What is the difference


alfa2
03-19-2006, 12:02 AM
What is the difference between these xml files...

loading a flv video.

<xml>

<index url = "file.flv"/>

</xml>

and

<xml>

<index>file.flv</index>

</xml>

when I try the first option works but when I use the second option does not
work why and how do I make it to work...

Thanks for the supplies.

colfaxrev
03-19-2006, 12:13 AM
What is the difference between these xml files...

loading a flv video.

<xml>

<index url = "file.flv"/>

</xml>

and

<xml>

<index>file.flv</index>

</xml>

when I try the first option works but when I use the second option does not
work why and how do I make it to work...

Thanks for the supplies.

the first one uses attributes, and the second uses the more standard hiarchy approach.

to access the second when you load in your xml use this code


myXML = new XML();
myXML.ignoreWhite = true; //very important!
myXML.onLoad = function(ok)
{
if (ok)
{
trace(myXML.firstChild.firstChild.firstChild.nodeV alue);
//should give you "file.flv"
}
else
{
trace("file not found");
}
}
//almost forgot
myXML.load("yourfile.xml");

alfa2
03-19-2006, 01:13 AM
But when I try the second option it does not work here is the xml code

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(ns);

video_player.attachVideo(ns);

<content>

<game>Name of the Game</game>
<title>title</title>
<image>Image0.jpg</image>
<http>http://www.putfwd.com/index/putfwd-dl-action/id.4831/type.flv</http>

</content>

actionscript code:

var myXML = new XML();
myXML.ignoreWhite = true; //very important!
myXML.onLoad = function(bSuccess:Boolean)
{
if(bSuccess)
{
var list:Array = this.firstChild.childNodes;
for(i=0;i<list.length;i++)
{
player_btn.http = list[i].firstChild.nextSibling.nextSibling.nextSibling.fi rstChild;
player_btn.onRelease = function()
{
ns.play(this.http);
}
}
}
}

but when I try the attribute property it works but not this one.

colfaxrev
03-19-2006, 01:15 AM
then i suggest use what works

alfa2
03-19-2006, 01:37 AM
Thanks for the help colfaxrev

colfaxrev
03-19-2006, 01:51 AM
just remember that it works like this..

if your xml is


<xml>
<content>
<item>
<a>blah blah</a>
</item>
<item>
<a>blah blah</a>
</item>
<item>
<a>blah blah</a>
</item>
</content>
</xml>


then to get the childNodes of content you need to use

xmlInstance.firstChild.firstChild.childNodes;

you have to use firstChild once to even get inside the xml at all!