Click to See Complete Forum and Search --> : XML Doubt


saju_m
04-18-2003, 04:59 AM
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

khalidali63
04-18-2003, 06:32 AM
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