I have a C# program that sends an XML string as this:
<?xml version="1.0" encoding="utf-16" standalone="no"?>
<ScoreList>
<Player UserName="Player1" Score="10" />
<Player UserName="Player2" Score="20" />
</ScoreList>
But when I receive it in my Python program it looks like this
b'<?xml version="1.0" encoding="utf-16" standalone="no"?>
\r\n<ScoreList>\r\n
<Player UserName="Player1" Score="10" />
\r\n <Player UserName="Player2" Score="20" />
\r\n</ScoreList>'
I'm sending it to a server with this code C#
Byte[] sendBytes = Encoding.BigEndianUnicode.GetBytes(doc);
netStream.Write(sendBytes, 0, sendBytes.Length);
And receiving with this code on the Python(Version 3.5) end
self.data = self.request.recv(1024).strip()
Then when I try to parse it using this code
tree = ET.fromstring(self.data)
I get the error:
File "<string>", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1,
column 1
Any advice on where I'm going wrong or what I could try to fix this.