[gdal-dev] RE: CPLXMLNode, no GetChilds()'like method ?
Aurélien Kamel
aurelien.kamel at magellium.fr
Thu Oct 16 04:29:45 EDT 2008
Actually I have one more question for you. Imagine you have an xml file like
this :
---- start of xml file ----
<?xml version="1.0"?>
<a b="xxx">
<b>
...
</b>
</a>
---- end of xml file ----
How can you access to the node "a" if you don't know its name ? I tried to
do a recursive function that would loop on all the nodes of the file
starting from ROOT.
With the following code I'll only recurse on the "<?xml version="1.0"?>"
node.
bool
MyDriver::parse(const char *filename) {
CPLXMLNode* xmlNode = CPLParseXMLFile(filename);
If (!xmlNode) return false;
return parseLoop(xmlNode);
}
bool
MyDriver::parseLoop(CPLXMLNode *node) {
std::cout << "Currently recursing on node: " << node->pszValue <<
std::endl;
for (CPLXMLNode *brother = node->psChild;
brother;
brother = brother->psNext)
if (!parseLoop(brother)) return false;
return true;
}
Any idea how I'll could recurse on all the nodes that are child of ROOT ?
Thanks,
aurel
-----Message d'origine-----
De : gdal-dev-bounces at lists.osgeo.org
[mailto:gdal-dev-bounces at lists.osgeo.org] De la part de Aurélien Kamel
Envoyé : mercredi 15 octobre 2008 16:28
À : gdal-dev at lists.osgeo.org
Objet : [gdal-dev] RE: CPLXMLNode, no GetChilds()'like method ?
I found my answer. I can use the public attribute psNext that point to the
next sibling.
Sorry.
aurel
-----Message d'origine-----
De : Aurélien Kamel [mailto:aurelien.kamel at magellium.fr]
Envoyé : mercredi 15 octobre 2008 16:24
À : 'gdal-dev at lists.osgeo.org'
Objet : CPLXMLNode, no GetChilds()'like method ?
Hello,
I have to parse a XML file in a driver I'm writing for OGR and I would like
to do a recursive method that would take a xml node as argument and then
call itself on each of the child of this node.
Is there a way to get the child list of a node with CPLXMLNode ? For the
moment I can't figure how I could do this with cpl_minixml...
http://www.gdal.org/cpl__minixml_8h.html
Thanks,
Cheers,
aurel
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list