www.webdeveloper.com
Results 1 to 2 of 2

Thread: XML Doubt

  1. #1
    Join Date
    Jan 2003
    Location
    Thiruvananthapuram, Kerala, India
    Posts
    27

    XML Doubt

    My doubt is

    i got one xml like
    <main>
    <block>

    <block>
    </block>

    <block>
    <block>
    </block>
    </block>

    </block>
    </main>
    this means that one block tag can have 0 or many block tags as child.
    problem is if i want to get all the block tags comes directly under main tag i ve to use getElementByTagNames() which returns the NodList here the problem is it returs all the tags under main tag and i need only the block tag which is directly under the main tag
    what should i do for that
    pls help
    thank you

    saju.m

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    First of all having the same name for block root element and the block child elements,will eventaully result in problems.I'd say thats bad design unless its just an example that you put here.
    Now for your question,Your XML documnet root element is main.say you are at the "main" elements level from here you can get
    root.getChildNodes()
    it would return a NodeList of all the first level childs that main has hence providing you with all the blocks that has more block elements

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles