xmlString = xmlNodeListGetString(a_docPtr, cur_node->xmlChildrenNode, 1);
if(xmlString!= NULL)
{
rc = xmlTextWriterWriteFormatElement(aWriter, BAD_CAST cur_node->name,"%s",BAD_CAST xmlString);Maybe you should use something like the following here...:
rc = xmltextWriterStartElement(sWriter, cur_node->name);
rc = xmlTextWriterWriteText(sWriter, xmlString);
...and leave the element open to be closed at the end of the function. I did not test this, but it seems that you get xmlTextWriterEndElement() called when you enter this branch of the if statement too, which can be the cause of your trouble.
xmlFree(xmlString);
}
else
{
rc = xmlTextWriterStartElement(aWriter, BAD_CAST cur_node->name);
}
}[...] .
rc = xmlTextWriterEndElement(aWriter);
}[...]
Servus -- Alfred