XMLUtil.cpp

Go to the documentation of this file.
00001 #include "XMLUtil.h"
00002 #include "wx/xml/xml.h"
00003 
00004 namespace XMLUtil
00005 {
00006   const wxXmlNode* findChildWithName(const wxXmlNode &parent, const char *name)
00007   {
00008     // First see if the passed in node is the one we are looking for
00009     if ( parent.GetName() == name )
00010       return &parent;
00011 
00012     // Go through the children looking for the node with the given name
00013     wxXmlNode *child = parent.GetChildren();
00014     if ( child )
00015     {
00016       if ( child->GetName() == name )
00017         return child;
00018 
00019       const wxXmlNode *node = findChildWithName(*child, name);
00020       if ( node )
00021         return node;
00022 
00023       const wxXmlNode *sibling = child->GetNext();
00024       while ( sibling )
00025       {
00026         if ( sibling->GetName() == name )
00027           return sibling;
00028         node = findChildWithName(*sibling, name);
00029         if ( node )
00030           return node;
00031         sibling = sibling->GetNext();
00032       }
00033     }
00034     return NULL;
00035   }
00036 
00037   const wxXmlProperty* findPropertyWithName(const wxXmlNode &node, 
00038                                             const char *name)
00039   {
00040     const wxXmlProperty *property = node.GetProperties();
00041     while ( property )
00042     {
00043       if ( property->GetName() == name )
00044         return property;
00045       property = property->GetNext();
00046     }
00047     return NULL;
00048   }
00049 };

Generated on Sat Dec 3 10:47:41 2005 for Robotics by  doxygen 1.4.5