Aurélien Kamel wrote:
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 ?
Aurel,
The code looks ok except that it misses the siblings of the root node.
In a case like the above file the "a" element will be a sibling of the
<?xml...> node, not a child.
There are numerous examples of code for recursing and searching the XML
document in gdal/port/cpl_minixml.cpp.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, [EMAIL PROTECTED]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev