XPathDocument (and XmlDocument) default to preserveWhitespace=false for
backward compatibility reasons.
news:8FFC95E9-B71E-477B-A428-6B17601A3CDD@microsoft.com...
Quote:
Hello;
>
First off, thank you for answering. Getting a definite no helps as then I
know that I'm not missing something.
>
Most cases I am passed a Stream so I can call new XmlDocument(Stream)
instead of new XPathDocument(Stream). But all of the documentation I have
read says that XPathDocument is a lot faster for heavy xpath use - so do I
then lose that efficiency?
>
And out of curiosity, why does XPathDocument eat all of the whitespace?
Because xml schemes like Excel's SpreadsheetML need it.
>
--
thanks - dave
>
>
"Chris Lovett" wrote:
>
>I'm on the .net xml team and I know for sure that once you've loaded an
>XmlDocument without preserveWhitespace, you have lost all insignificant
>whitespace information and there is no way for the XPathNavigator to
>"reinvent" it on the fly. Therefore you'll have to tell folks who are
>calling you not to do that. Or you chould change your component design
>so
>that they call you to load the XML that way you can be in control of how
>the
>whitespace processing happens.
>>
>"David Thielen" <thielen@nospam.nospamwrote in message
>news:71AED216-F755-4726-B5C1-6EDDFC5B332A@microsoft.com...
Hi;
>
It's not my xml. I have a library that other people call and pass me
their
xml. I wrote all of my code using XPathDocument & XPathNavigator
because
it
is the "suggested" approach.
>
But I need to have whitespace preserved. There must be a way as
Microsoft
suggests using this approach and not using XmlDocument at all. Could
you
please ask the .net team? I find it hard to believe they would not have
made
it possible to do this.
>
--
thanks - dave
>
>
"Kevin Yu [MSFT]" wrote:
>
>Hi dave,
>>
>There is no way to preserve whitespace in the code directly with
>XPathNavigator. You can try to do the following:
>>
>1. Add whiteSpace="preserve" in the tag. <space whiteSpace="preserve">
></space>
>2. If the node is a whitespace, check the XPathNavigator.NodeType
>property,
>it has to be XPathNodeType.SignificantWhitespace or
>XPathNodeType.Whitespace.
>>
>Kevin Yu
>=======
>"This posting is provided "AS IS" with no warranties, and confers no
>rights."
>>
>>
>>
>>
>>