Note that there are some explanatory texts on larger screens.

plurals
  1. POBest Practices for AS3 XML Parsing
    primarykey
    data
    text
    <p>I've been having some trouble parsing various types of XML within flash (specifically FeedBurner RSS files and YouTube Data API responses). I'm using a <code>URLLoader</code> to load a XML file, and upon <code>Event.COMPLETE</code> creating a new XML object. 75% of the time this work fine, and every now and again I get this type of exception:</p> <pre><code>TypeError: Error #1085: The element type "link" must be terminated by the matching end-tag "&lt;/link&gt;". </code></pre> <p>We think the problem is that The XML is large, and perhaps the <code>Event.COMPLETE</code> event is fired before the XML is actually downloaded from the <code>URLLoader</code>. The only solution we have come up with is to set off a timer upon the Event, and essentially "wait a few seconds" before beginning to parse the data. Surely this can't be the best way to do this.</p> <p>Is there any surefire way to parse XML within Flash?</p> <p><strong>Update Sept 2 2008</strong> We have concluded the following, the excption is fired in the code at this point:</p> <pre><code>data = new XML(mainXMLLoader.data); // calculate the total number of entries. for each (var i in data.channel.item){ _totalEntries++; } </code></pre> <p>I have placed a try/catch statement around this part, and am currently displaying an error message on screen when it occurs. My question is how would an incomplete file get to this point if the <code>bytesLoaded == bytesTotal</code>?</p> <hr> <p>I have updated the original question with a status report; I guess another question could be is there a way to determine wether or not an <code>XML</code> object is properly parsed before accessing the data (in case the error is that my loop counting the number of objects is starting before the XML is actually parsed into the object)?</p> <hr> <p>@Theo: Thanks for the ignoreWhitespace tip. Also, we have determined that the event is called before its ready (We did some tests tracing <code>mainXMLLoader.bytesLoaded + "/" + mainXMLLoader.bytesLoaded</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload