SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Flex XML parsing

    Hi there,

    I'm programming in AS3 with Flex Builder 3 and have a question. I'm parsing XML that has many different node names. To make my life easier I have these node names in an array. I want to parse the array, grab blocks of XML that coorespond to the sections as stored in the array. This bombs out however and doesn't seem to be possible. Here's an example:

    Demo XML:
    Code:
    <website>
       <health>
            <page num="1" type="link" />
            <page num="2" type="url" />
       </health>
       <safety>
            <page num="1" type="link" />
            <page num="2" type="url" />
       </safety>
    </website>
    As shown above I want to access the sections health and safety where each are their own indicy in the array. Here's my AS3 code and flex.

    Code:
    private var siteSections:Array = new Array("health","safety");
    
    for (var i:Number = 0; i < this.siteSections.length; i++) {   // we want to iterate over all the sections
    // this.currXML contains the block of website XML
    for each (var currentPage:XML in this.currXML.siteSections[i].page) {
    
    if (currentPage.@id == 0) {
    	this.siteTree += "<folder label=\""+currentPage.@id+"\" section=\""+siteSections[i]+"\" isleftnav=\"\"></folder>";
    }
    
    }
    
    }
    If you see above the values stored in siteSections are going to be dynamically listed to pull in the right section from the approp. index in the array. I get no results back. I even tried converting the value in siteSections to an XMLNode but that didn't work either. Any help would be greatly appreciated.

  2. #2
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You dont need to use an array to store names of nodes of xml file, using NameSpace you can directly access the xml nodes by their names.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  3. #3
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jim_morrison3

    do u have any resource that you can share with us regarding the flex.

    i think u know i am a flash programmer and i am very curious about FLEX.

  4. #4
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dijup View Post
    jim_morrison3

    do u have any resource that you can share with us regarding the flex.
    There are many online resources to learn Flex, I dont know if I have any resource as such as I learned Flex just by practicing and working on live projects.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  5. #5
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think it will be grate help if u provide us some help link for flex.

  6. #6
    SitePoint Guru [Paul Ferrie]'s Avatar
    Join Date
    Oct 2007
    Location
    Glasgow, Scotland, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dijup View Post
    i think it will be grate help if u provide us some help link for flex.

    Flex help tutorials

    Google is your friend.
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher
    bringmadeleinehome.com

  7. #7
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by [Paul Ferrie] View Post

    Flex help tutorials

    Google is your friend.
    we all know that there are many things in google but my fren google is not the world.

  8. #8
    SitePoint Guru [Paul Ferrie]'s Avatar
    Join Date
    Oct 2007
    Location
    Glasgow, Scotland, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's the first place i start before posting for help or when i am giving help and advice on the dev forums.
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher
    bringmadeleinehome.com


Bookmarks

Posting Permissions

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