开发者

Unicode escape characters not being read by XmlReader

I've got an XML document that I'm importing into an XmlReader that has some unicode formatting I need to preserve. I'm preserving the whitespace but it开发者_如何学Python's dropping the encoded #x2028 which I assume should be expressed as a line break.

Here's my code:

var settings = new XmlReaderSettings
                   {
                       ProhibitDtd = false,
                       XmlResolver = null,
                       IgnoreWhitespace = false
                   };

var reader = XmlReader.Create(new StreamReader(fu.PostedFile.InputStream), settings);
var document = new XmlDocument {PreserveWhitespace = true};
document.Load(reader);
return document;

XML example:

<td valign="top" align="center">Camels and camel &#x2028;resting place</td>

How do I get to those characters to I can render br tags?


Your question is unclear: do you expect the XmlReader to translate the &#x2028; into an HTML <br> tag? That isn't going to happen.

Or are you examining the actual character content of the <td> element (within the code, not as printed/displayed) and seeing "camel resting place"? If yes, please show the code that you're using to verify this, because it would be a pretty major bug.

Or something else?


After importing the code into the reader I was able to find and replace that character:

Regex.Replace(s, "\u2028", "<br/>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜