bakery r112 - in trunk: . bakery/Document



Author: murrayc
Date: Sun Mar 30 20:15:25 2008
New Revision: 112
URL: http://svn.gnome.org/viewvc/bakery?rev=112&view=rev

Log:
2008-03-30  Murray Cumming  <murrayc murrayc com>

* bakery/Document/Document_XML.cc: get_node_child_named():
Try all the child nodes until we find one that is an Element, or we 
reach the end. This avoids a problem with Elements with the name text, 
because Node::get_children() also returns TextNode nodes when asked for 
text nodes.

Modified:
   trunk/ChangeLog
   trunk/bakery/Document/Document_XML.cc

Modified: trunk/bakery/Document/Document_XML.cc
==============================================================================
--- trunk/bakery/Document/Document_XML.cc	(original)
+++ trunk/bakery/Document/Document_XML.cc	Sun Mar 30 20:15:25 2008
@@ -174,8 +174,16 @@
   if(node)
   { 
     xmlpp::Node::NodeList list = node->get_children(strName);
-    if(!list.empty())
-      nodeResult = dynamic_cast<xmlpp::Element*>(*(list.begin()));                         
+
+    //We check all of them, instead of just the first, until we find one,
+    //because get_children() returns, for instance, TextNodes (which are not Elements) for "text", 
+    //as well as Elements with the name "text".
+    for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
+    {
+      nodeResult = dynamic_cast<xmlpp::Element*>(*iter);  
+      if(nodeResult)
+        return nodeResult;
+    }                       
   }
 
   return nodeResult;



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