0

I am migrating from AS2 to AS3 and ran into trouble grabbing nodes from XML. I am able to grab (and trace) the entire XML file in AS3 but want to be able to store the first tag as a node using firstChild and loop through the tags using nextSibling. But in AS3 the firstChild keeps coming up empty, when my previous AS2 code would actually grab the content. What am I doing wrong? (and I can't call tags by their names because I reuse the code block for multiple xml files)

var eRoot = exampleXML.firstChild;
while (eRoot != null) {
  //do stuff
  eRoot= eRoot.nextSibling;
}

My test XML file:

<?xml version="1.0" encoding="UTF-8"?>
<content>
    <version>cd</version>
    <lessonlock>~-*~-*</lessonlock>
    <expiryDate>**#*#**##**##**##*##********###*</expiryDate>
    <isSpanish>true</isSpanish>
    <server>http://www.exampleSite.com</server>
</content>
4

1 回答 1

2

That's because neither firstChild nor nextSibling exist as properties on an AS3 XML object. The way you are doing it, you are searching for the nodes <firstChild> and <nextSibling>.

You should read the API for XML, and better yet, Adobe's guide to E4X.

于 2012-04-20T18:39:59.947 回答