Reputation: 9757
I am attempting to figure out why some text apparently doesn't have any carriage returns in it, even though it looks like it does. I am wondering if calling innerText when Xpath'ing through a XmlDocument (in .net 4.0) strips carriage returns or other characters. Probably not, But at this point I looking for anything.
Upvotes: 0
Views: 1577
Reputation: 113322
What's the xml:space
on the element? If you need to force it to be preserve whitespace other than significant whitespace, then you can set PreserveWhitespace
to true
before calling Load
or LoadXML
.
Be cautions with this though as in most cases the person writing the XML will expect the normal XML rules for whitespace to be followed. Even worse, if you get a "works for me" by using the non-standard rules that PreserveWhitespace
uses, there's no reason you should expect anyone else to parse it as you intend.
Upvotes: 2
Reputation: 1502106
You haven't shown any code, so it's hard to know where the data came from. By default, insignificant whitespace is not preserved when loading an XmlDocument
. You might want to try setting XmlDocument.PreserveWhitespace
to true before loading.
If that doesn't help, please post a short but complete program which demonstrates the problem.
Upvotes: 3