www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - arsd.dom getElementsByTagNameChildrenOnly?

reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
So the vulkan spec has a lot of stuff like
<types>
<type category="struct" name="VkBufferCreateInfo">
             <member><type>VkStructureType</type>        
<name>sType</name></member>                          <!-- Must be 
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO -->
             <member>const <type>void</type>*            
<name>pNext</name></member>                          <!-- Pointer 
to next structure. -->
             <member 
optional="true"><type>VkBufferCreateFlags</type>    
<name>flags</name></member>                          <!-- Buffer 
creation flags -->
             <member><type>VkDeviceSize</type>           
<name>size</name></member>                           <!-- 
Specified in bytes -->
             <member><type>VkBufferUsageFlags</type>     
<name>usage</name></member>                          <!-- Buffer 
usage flags -->
             <member><type>VkSharingMode</type>          
<name>sharingMode</name></member>
             <member optional="true"><type>uint32_t</type>         
       <name>queueFamilyIndexCount</name></member>
             <member noautovalidity="true" 
len="queueFamilyIndexCount">const <type>uint32_t</type>*        
<name>pQueueFamilyIndices</name></member>
...
</ type>
...
</types>
How do I iterate over the child level elements only (ignoring the 
ones like <type>VkStructureType</type>)?
Do i have to check their parentage each time or is there an 
easier way?
Feb 23 2016
parent Adam D. Ruppe <destructionator gmail.com> writes:
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.)
Feb 23 2016