arsd.dom getElementsByTagNameChildrenOnly?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 23 06:24:59 PST 2016


On Tuesday, 23 February 2016 at 11:10:17 UTC, Nicholas Wilson 
wrote:
> How do I iterate over the child level elements only (ignoring 
> the ones like <type>VkStructureType</type>)?

Element.childNodes gives only direct children.

You could also do

document.querySelectorAll("types > type")

to get only the <type> tags that are a direct child of <types>.

(If you've ever done CSS or Javascript, this is similar syntax. I 
didn't implement the whole selector syntax and haven't kept up 
with any of the bleeding edge stuff, but all the basics work the 
same way.)


More information about the Digitalmars-d-learn mailing list