dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: new with XML[HELP]

  1. #1
    14 year old W.I.Z!
    Join Date
    Jul 2005
    Location
    USA
    Posts
    227

    new with XML[HELP]

    Hello, I'm new with XML, so I don't know a lot about it, but how can I get the information from XML to Flash? I am testing my skills, with dynamic boxes that have the variables of:"txt" and "txt2". This is the Flash code inside of my Flash doc:
    Code:
    test_xml = new XML();
    test_xml.ignoreWhite = true;
    test_xml.onLoad = function(sucess) {
    	if (sucess) {
    		processTest(test_xml);
    	}
    };
    test_xml.load('test.xml');
    function processTest(xmlDoc_xml) {
    	txt = (xmlDoc_xml.firstChild.firstChild.firstChild.nodeValue);
    	txt2 = (xmlDoc_xml.firstChild.firstChild.firstChild.firstChild.nodeValue);
    }
    In my XML file, I have:
    PHP Code:
    <?xml version="1.0"?>
    <text1>
    <number>2</number>
    <sentence>Hey</sentence>
    </text1>
    For some reason, the first text works but not the second. Any help?
    -Cobra
    Excuse my horrible spelling....you can blame my English teacher for that!

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    i am assuming that you are trying to get the values 2 and hey?

    If this line gets the value 2:
    txt = (xmlDoc_xml.firstChild.firstChild.firstChild.nodeV alue);

    then the second line should have a xmlDoc_xml.firstChild.childNodes[1].firstChild.NodeValue.

    Only nodes inside another node are child nodes. So both number and sentence are child nodes of text1.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center