Hello,

this sample code:
xmlDocPtr doc = xmlNewDoc((xmlChar*) "1.0");
xmlNodePtr root = xmlNewNode(NULL,(xmlChar*) "myxmldoc");
xmlDocSetRootElement(doc, root);
xmlNewTextChild(root, NULL, (xmlChar*)"mynode", (xmlChar*)"A text with signs 
\016 and & and < and >.");

xmlSaveCtxtPtr ctxt = xmlSaveToFilename ("mypath/myfile.xml", "UTF-8", 
XML_SAVE_FORMAT| XML_SAVE_AS_XML);
xmlSaveDoc(ctxt, doc);
xmlSaveClose(ctxt);
xmlFreeDoc(doc);

leads to this xml file:
<?xml version="1.0" encoding="UTF-8"?>
<myxmldoc>
  <mynode> A text with signs  and &amp; and &lt; and &gt;. </mynode>
</myxmldoc>

Between "signs " and " and" is the \016 (or 0x0e) byte. The hexdump -Cv shows 
it:
... 73 20 0e 20 61 ...

Now I try to read this file:

doc = xmlReadFile("mypath/myfile.xml", NULL, 0);

This leads to this message:
mypath/myfilexml:3: parser error : xmlParseCharRef: invalid xmlChar value 14
  <mynode> A text with signs and &amp; and &lt; and &gt;. </mynode>
                            ^

My problem is: The xml2-library accepts in the API bytes without error and it 
saves these data, but reject them on loading. :-(

In my point of view it would be better if the behavior would be the similar in 
loading and API-calls. Or is there a special reason for this different behavior.

kind regards

Andreas Schigold

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to