tags:

views:

57

answers:

2

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'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?

A: 

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?

Anon
I want to replace that Unicode point with a br tag. I figured it out, thanks though.
craigmoliver
A: 

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

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