From: Francesco M. <f18...@ya...> - 2006-09-28 16:13:06
|
Ildar ha scritto: > and one more ;) > > is there a way to get a count of nodes? currently no; that's because wxXml2 API derives from wxXml API because when I wrote it I wanted to port some wxXml code to a newer API with DTD validation and thus I made wxXml2 API mostly compatible with wxXml one, which has no GetChildCount() methods. However I agree this would be useful to have. Patches welcome :D > e.g. > > - Find(...) allows to get the N-th node which meets the condition, but what's > the number of nodes which meet the condition? we could add a new GetChildrenCount(const wxXmlNode &tofind, bool bNS = TRUE, bool recurse = TRUE) function to return it > - or how to get the number of wxXML_ELEMENT_NODE subnodes of wxXML_ELEMENT_NODE > node? I would add a GetChildrenCount() const function for this. > I understand I can enumerate the nodes and count them, is it the only possible > solution? it highly depends on how to you want to organize your parser. For me, the pattern I copied & pasted in previous mail has always been a winning pattern ;) I.e. you scan all the XML document, handle unknown tags in the else{} part, and call subroutines to load other nodes in other elseif{} branches. It's a lot of time I don't look at XML Schemas, SAX parser, etc. You can get an idea of the "low-level" libxml2 API looking at http://xmlsoft.org/html/index.html Francesco |