c - Empty element causing libxml segfault -


i have xml file goes this:

<root>   <children>     <child />   </children>   <otherchildren>   </otherchildren>   <morechildren>     <child />   </morechildren> </root> 

and here's c parses it:

doc = xmldocptr; doc = xmlparsefile(file); cur = xmlnodeptr; cur = xmldocgetrootelement(doc); cur = cur->xmlchildrennode;  while (cur != null){ // loop through children of root      // thing      cur = cur->next; } 

when xmlnodeptr comes otherchildren, because there no contents, next node (the text node) null

this gives me problem, messes loop, , causes segfault somehow.

how fix other obvious if statement? there more xml below otherchildren , can't if loop exits.

using .xml, get:

./sotrials ../untitled1.xml  ../untitled1.xml:10: parser error : expected '>' </root> ^ error: not parse file ../untitled1.xml speicherzugriffsfehler 

(speicherzugriffsfehler = memory fault)

changing .xml to

... </morechildren> ... 

gives:

./sotrials ../untitled1.xml  node type: element, name: text node type: element, name: children node type: element, name: text node type: element, name: otherchildren node type: element, name: text node type: element, name: morechildren node type: element, name: text 

looks code better xml.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -