I have a problem with entities and wonder how to fix it :

My python program using libxml2 python binding ( 2.7.3 ) to create a xml
document.
I create an windows binary executable using py2exe.

For some nodes the content contains german umlauts.
Depending on which PC I ran the program the resulting xml
either contains the umlaut characters or an strange entity text !?

Here is my code to fill text into a node :

A xmlDoc instance created using

theDoc = libxml2.newDoc("1.0")

text is unicode data.

theNode = libxml2.newNode("MyNode")
theNode.addChild( libxml2.newText( theDoc.encodeEntitiesReentrant(
text.encode("utf-8") ) ) )

To save the document to a file I do

theDoc.saveFileEnc( path_to_the_file, "utf-8" )

The resulting document contains depending on which PC the program ran :

<MyNode>Some Text &amp;#xF6;&amp;#xE4;&amp;#xFC;</MyNode>

or

<MyNode>Some Text öäü</MyNode>
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to