special character encoding in XML
Posted on 2009-07-06
I am using python's xml.dom.minidom to create a service that simulates a production server, and I'm using this service on my local machine to test software, rather than hitting the production server for my testing.
While simulating the responses from the production server, there's one part I haven't been able to accurately reproduce...
The server will respond with an xml element like this:
<Item Name="TSCDATA" Value=":020000040001F9
notice the "
" which is used as an EndOfLine character
I can't get my simulator program to create that same sequence of characters. The problem is not the content, it's the line delimiter character. I can't make the "
I get something like this:
<Item Name="TSCDATA" Value=":02000004DE011B\&#xA;:08000000081022003800000086\&#xA;:08000800081022D020000000C6\&#xA;:08001000081042E0200000008E\&#xA;:08001800061042D02000000098\&#xA;:08002000062042E02000000070\&#xA;:08002800062041D02000000079\&#xA;:08003000042041C02000000083\&#xA;:08003800041041B0200000009B\&#xA;:00000001FF"/>
I've tried a number of variations.
When I supply this as an EOL: "
", the minidom encodes it as this: "&#xA;"
When I supply this: "\
", the minidom encodes it as "\&#xA;"
When I supply this: "&
", the minidom encodes it as "&&#xA;"
When I supply this: "\n", the minidom does not encode it, and leaves it as a linefeed.
How can I tell the minidom engine to either NOT encode the "
or force it to encode "\n" as "