XML gives undefined result in ActionScript 2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex001
    New Member
    • Sep 2010
    • 1

    XML gives undefined result in ActionScript 2.0

    This is one of XML file which I have:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <root>
    	<document>
    		<title>What is lorem ipsum ?</title>
    		<description>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</description>
    	</document>
    </root>


    The ActionScript code is this

    Code:
    function loadXML(loaded) { if (loaded) { xmlNode = this.firstChild; _root.simple_title = []; _root.simple_description = []; total = xmlNode.childNodes.length; for (i = 0; i < total; i++) { xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; } } else { trace("XML is not loaded!"); } }
    
    xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("simple.xml");
    Now everything it's okay in the root timeline actually it's work for example I've one movieclip called content and inside them I have 2 textfields the title and description text now I try to call in root and that's work

    Code:
    content.titleID.text = simple_title[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; content.descriptionID.text = simple_description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    Now I try to call from content movieclip the childNodes from root for example:

    Code:
    titleID.text = _root.simple_title[0] descriptionID.text = _root.simple_description[0]
    Now the XML gives undefined result, yes that's the issue which I can't do!
    Last edited by Niheel; Sep 14 '10, 08:16 PM. Reason: merged to include the added question details into the question
Working...