ignore non-leaf text nodes
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 21 May 2007 16:33:29 +0000 (16:33 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 21 May 2007 16:33:29 +0000 (16:33 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@913 9efc2488-bf62-4759-914b-345cdb29e865

src/utils/xml_utils.c

index 15a350b..cb2164f 100644 (file)
@@ -48,10 +48,16 @@ jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject* obj) {
                }
 
                xmlNodePtr child = node->children;
-               while(child) {
-                       _xmlToJSON(child, new_obj);
-                       child = child->next;
-               }       
+                if (child) { // at least one...
+                       if (child != node->last) { // more than one -- ignore TEXT nodes
+                               while(child) {
+                                       if (child->type != XML_TEXT_NODE) _xmlToJSON(child, new_obj);
+                                       child = child->next;
+                               }
+                       } else {
+                               _xmlToJSON(child, new_obj);
+                       }
+                }
        }       
 
        return obj;