Re: [libxml++] get_children



On Mon, Jul 18, 2005 at 11:08:21PM +0000, panoply att net wrote:

> If I have the following document:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <truck id="tip" targ="gamestart">
>   <boat id="menuMatrix">
>   </boat>
>   <state id="start">
>   </state>
> </truck>
> 
> ...and through the document provided by the domparser, I have obtained the root element, then should'nt it be true that a "get_children()" call on that root element would return 2, since the root (e.g. "truck") element has only two sub-elements?  Am I missing something here?  I always get a number several higher than what the document presents for child-elements of the root node.

There are empty text node children of the root as well:

<truck>
 |
 |--text node
 |
 |--<boat>
 |   |
 |   |--text node
 |
 |--text node
 |
 |--<state>
 |   |
 |   |--text node
 |
 |--text node

You can set parser options so that empty text nodes are stripped when
building the dom tree.

regards,

jon





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]