Hi there,

I think I have a simple question, but I have not been able to figure this out.
I have an XML file that I am importing in from a blog.
Some of the <item> tags have <enclosure> tags, and some do not.
I want AS3 to test for the presence of an <enclosure> tag, and if it exists, 
get the URL.
However, if it does not exist, I want AS3 to do nothing, or return empty.

Unfortunately, what is happening is this: If AS3 does not find an <enclosure> 
tag in a 
particular <item>, it goes to the next item to look for it. This has the 
unhappy 
consequence of associating an <enclosure> with an <item> that it does not 
belong with. 

Furthermore, when AS3 reaches the end of the list, it decides that the last 
<items> do not 
have <enclosure> tags because it has used up all of the <enclosure> tags in the 
XML. So 
all of my "no enclosure" messages are at the bottom.

Here is the code:

var myxml = new XML(xmlclean);
var il:XMLList = myxml.channel.item;
for (var i:uint = 0; i<il.length(); i++) {

if(myxml.channel.item.enclosure[i])
{
        trace([EMAIL PROTECTED]);
}
else
{
trace("no enclosure");
}

Thanks for your help! I tried to find an answer by searching the archives, but 
they returned 
more than 5000 messages for "XML" and even "XML enclosure."

sj

Reply via email to