Ariff
11-02-2007, 02:02 AM
Hello,
im trying to setup a news section which publishes a header/body into an swf.
I created an XML file with the following layout :
<news>
<subject active = "true">
<header>This is the active article</header>
<body>Hi there, i am the active article of today</body>
</subject>
<subject active = "false">
<header>This is another article</header>
<body>This is another article</body>
</subject>
<subject active = "false">
<header>Article 3</header>
<body>this is article number 3</body>
</subject>
</news>
i use the following code in flash to "parse" the xml data :
function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
xmlList = xml.children();
//trace(xml.children().length());
for (var i=0; i <= xml.length(); i++){
//trace(i);
if (xml.child(i).@active == "true"){
trace("The active article is :" +xml.child(i).parent);
}
}
What im trying to accomplish is the following :
- im trying to browse through the xml file, with a for loop, to obtain the "active" article, once found, i need to obtain the header and body for that active article and push those to some textfields on stage. I have been trying to get the data i need out of it, but the XML and xmlList object really have me confused. Anyone who could give me a hand, or point me to some in-depth explanations of the xml/xmlList objects. I have been reading up on the livedocs from adobe, but that didn't get me much smarter on this matter.
Kind regards,
Juan
im trying to setup a news section which publishes a header/body into an swf.
I created an XML file with the following layout :
<news>
<subject active = "true">
<header>This is the active article</header>
<body>Hi there, i am the active article of today</body>
</subject>
<subject active = "false">
<header>This is another article</header>
<body>This is another article</body>
</subject>
<subject active = "false">
<header>Article 3</header>
<body>this is article number 3</body>
</subject>
</news>
i use the following code in flash to "parse" the xml data :
function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
xmlList = xml.children();
//trace(xml.children().length());
for (var i=0; i <= xml.length(); i++){
//trace(i);
if (xml.child(i).@active == "true"){
trace("The active article is :" +xml.child(i).parent);
}
}
What im trying to accomplish is the following :
- im trying to browse through the xml file, with a for loop, to obtain the "active" article, once found, i need to obtain the header and body for that active article and push those to some textfields on stage. I have been trying to get the data i need out of it, but the XML and xmlList object really have me confused. Anyone who could give me a hand, or point me to some in-depth explanations of the xml/xmlList objects. I have been reading up on the livedocs from adobe, but that didn't get me much smarter on this matter.
Kind regards,
Juan