Categories

Partners
  • Website Templates

  • Design Feeds

  • Adobe Photoshop Tutorials

  • Website Templates, WordPress Themes

  • Website Templates

  • Flash Web Sites

  • Photoshop Templates

  • Photo Contests

  • Photo Tips
  • Search


    Advanced Search


    Partner Links
  • Adobe Photoshop Tutorials

  • Free Stock Photos and Images



  • Website Templates

    Parsing an XML Packet in Flash
    Published  06/19/2006 | Macromedia Flash
       




    Parsing an XML Packet in Flash

    1. // if the XML packet was a simple packet using attributes.
    2. var login_xml:XML = new XML("<?xml version=\"1.0\" ?><login status=\"success\" sessionid=\"57754B095346D64A\" />");
    3. trace("status: "+login_xml.firstChild.attributes.status);
    4. trace("sessionid: "+login_xml.firstChild.attributes.sessionid);
    5. trace("");
    6. // if the XML packet had child nodes.
    7. var login_xml:XML = new XML("<?xml version=\"1.0\" ?><login><status>success</status><sessionid>57754B095346D64A</sessionid></login>");
    8. trace("status: "+login_xml.firstChild.childNodes[0].firstChild.nodeValue);
    9. trace("sessionid: "+login_xml.firstChild.childNodes[1].firstChild.nodeValue);
    10. trace("");
    11. // parse XML packet using a for loop to loop over the childNodes
    12. var login_xml:XML = new XML("<?xml version=\"1.0\" ?><login><status>success</status><sessionid>57754B095346D64A</sessionid></login>");
    13. for (var i = 0; i<login_xml.firstChild.childNodes.length; i++) {
    14.     trace(login_xml.firstChild.childNodes[i].nodeName+": "+login_xml.firstChild.childNodes[i].firstChild.nodeValue);
    15. }
    Article Series
    This article is part 7 of a 13 part series. Other articles in this series are shown below:
    1. Flash FAQ - Introduction
    2. Streaming FLV files in Flash MX 2004
    3. Creating an XML Packet with Flash - the easy way
    4. Creating an XML Packet with Flash - the hard way
    5. Getting more colors for your Halo
    6. Loading in Images Using the MovieClipLoader Class
    7. Parsing an XML Packet in Flash
    8. Parsing XML in Flash Using the XMLConnector
    9. Sending an XML Packet to a Server-Side Page
    10. Using LoadVars.send Method to Exchange Data with a Server-Side Script
    11. Using the Alert component
    12. Using the LoadVars Class to Load Variables
    13. Using XPath in Flash MX 2004