简体   繁体   中英

detecting empty fields in XML trough FLASH AS2

I have this simple XML file, witch I'm calling in a SWF file. This is the code:

<goals1>
<minute>32</minute>
<name>Name</name>
<minute>35</minute>
<name>Name2</name>
</goals1>

So these nodes are going to be empty. They are even not going to exist. But I'm going to put the paths in to the AS2. So my question is: - What to do to make them not showing "undefined" in the swf file. In other words I need to display content when there is any.

Thank You!

If you got no whitespace, you'd simply check is that node is empty or not.

if (example.nodeValue != '') {
    // Run your stuff
}

You could also run a for() based on the length of an xml object to only execute given children.

Something like this:

xmlFeed.onLoad = function() {
    // Pre defined and go the depth you need
    parsedXML = xmlFeed.firstChild.firstChild.childNodes;

    for (var i:Number = 1; i <= parsedXML.length; i++) {
        if(parsedXML[i].firstChild.nodevalue != "") {
            // Run your stuff here
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM