A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Defining variables from an XML file.....

  1. #1
    Dreamshock Design scooter41's Avatar
    Join Date
    May 2000
    Location
    Nr Brighton, UK
    Posts
    222

    Defining variables from an XML file.....

    Hi There,

    I am currently stating each and every variable I retrieve via an xml document, like the following:

    _root.questionT = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    _root.answerA= xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    _root.answerB = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
    _root.answerC = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;

    Is there anyway to automate this so it simply reads in the name of the surrounding text?

    <frontText>Welcome to our website</frontText>

    So it would know that this variable was frontText without me specifying it? Is that possible?
    Scott Wright
    Dreamshock Design Studios LTD
    www.dreamshock.com

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    have a look at using XPath if you are trying to grab hold of particular nodes... heres an explanation:

    http://tutorials.lastashero.com/2005..._in_flash.html
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Dreamshock Design scooter41's Avatar
    Join Date
    May 2000
    Location
    Nr Brighton, UK
    Posts
    222
    that is perfect, just what the doctor ordered

    thanks heaps for this
    Scott Wright
    Dreamshock Design Studios LTD
    www.dreamshock.com

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    your welcome, glad i could help
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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