Does anyone have any idea on how I can strip the extra whitespace in
the XML that shows up when I receive a response from an ASP.NET 2.0
webservice? This has been discussed before, but no one has ever come up
with a good answer to what seems like such a common question.
http://groups.google.com/group/micro...fff1b27460a421
http://groups.google.com/group/micro...240db31e1d3fe7
http://groups.google.com/group/micro...a3026a4d286e63
It just seems very silly to have it included since another program will
be consuming it, and since that other program could care less about
whitespace. Not only is it a waste of bandwidth (albeit not _that_
much), but it causes serious implications for me when I try to parse
through the XML document in JavaScript.
For example, if the XmlDocument that I return has two nodes on it, the
child nodes of the root element of the response has five child nodes in
JavaScript when I parse the doc in Firefox (two are my elements, and
three are the whitespace). IE does return that there are two child
nodes, but the whitespace is still there nonetheless. I can code around
it by building a function that looks for the right tag name or that
ignores whitespace elements, but it's dumb that I'd have to do that in
the first place.
Also, contrary to the other posters, I am certain that in this case the
whitespace actually does come from the server and isn't being inserted
in the document for readability reasons or whatever. I've used Fiddler
and taken a look at the hex data that comes back, and, sure enough,
there is a <CRLFat the end of every node and the indent spaces at the
beginning of every node.
Any takers on this question that seems to have been around forever
without a good answer?