PDA

View Full Version : QDomElement::elementsByTagName()



manojmka
27th May 2008, 07:37
Hi,

I have an xml document having nested tags with same name. When I try to get a list of tags with using elementsByTagName() functions from QDomElement, it return me a list of all elements (including the nested ones in preorder traversal method). I only want the list of direct children with name "Page". Can someone please tell me how to do that??

Here follows the a sample portion of xml file:

<Root>
<PageCount>5</PageCount>
<Page Type="C">
<Pos>10</Pos>
<Page Type="L">
--------
--------
</Page>
<Page Type="R">
--------
--------
</Page>
-------
-------
</Page>
<Page Type="D">
<Pos>10</Pos>
<Page Type="L">
--------
--------
</Page>
<Page Type="R">
--------
--------
</Page>
-------
-------
</Page>
<Page Type="M">
<Pos>10</Pos>
<Page Type="L">
--------
--------
</Page>
<Page Type="R">
--------
--------
</Page>
-------
-------
</Page>
<Page Type="D">
<Pos>10</Pos>
<Page Type="L">
--------
--------
</Page>
<Page Type="R">
--------
--------
</Page>
-------
-------
</Page>
<Page Type="L">
<Pos>10</Pos>
<Page Type="L">
--------
--------
</Page>
<Page Type="R">
--------
--------
</Page>
-------
-------
</Page>
</Root>

Regards,
Manoj

wysota
27th May 2008, 11:43
Take a look here:
http://blog.wysota.eu.org/index.php/2007/04/27/domelementcontainer/