[xml] Strange entity strings of german umlauts in nodes content

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>


<MyNode>Some Text ÃÃÃ</MyNode>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]