Weird characters in web service output


I'm testing a customer web service that returns a string output in XML format. When loading the XML into my web browser it complains it's not well-formed - see attach. While trying to find the parsing error I detected some weird invisible characters in the output string. Is there a way to fully detect and fix this behavior? Is it an encoding problem?

Really appreciated for all the help!

First of all, it could be anything.

With which encodig is the file saved, what is the encoding inside the xml-tag
To check what special-char it is, open it with an proper text-editor which can also show the hex-values

You can detect the behaviour if you load it in a xml-parser (could be the xml-extension for example)
Fixing is also possible, but who has to fix it... the customer or you

Hi Joost,

that's exactly what I'm trying to find. I'm using Notepad++ Any idea of how can I show the hex-values of this output?

The xml tag doesn't seem to specify any encoding: <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">


Okay, I found the problem. Symbols like é , ç , ú or ã are responsible for the malformed XML.

How can this be fixed from the web service source code?

well, to be honest. the xml is not malformed.
encoding is not set right.

either don't use those chars, or set the encoding right

Bingo, Joost. Thanks!
About the fix, since we can't get rid of the characters the only option is to set the encoding properly. According to this can be achieved by specifying an <?xml ... ?> tag. This implies changing the web service :(

Is there any way to inject or parse the xml with this explicit encoding? Currently, the XmlDocument_Load action from Xml extension does not provide this functionality...
Hi Pedro,

Given that the XML file is stating a wrong encoding, then you are in fact dealing with an incorrect XML. Due to that, the Load operation will probably always have problems parsing it.

One simple option I can see is correcting the file directly (in the XML string) before loading it with the XML extension.


Daniel Lourenço

Hi Daniel,

Thanks for the reply.

I was actually thinking about that, but I decided to feed the XML directly (with no encoding spec) to the XmlDocument_Load action from Xml extension...and it works :| Go figure...

But thanks for the suggestion, I'll keep it in mind in the future.


wow, better change the webservice. I know it's not mandatory according the specs to provide encoding,
but if you use special characters it has to be provided. simple as that!
Really, blame the consumers webservice. it's a bad design!