0

I have Xml witch a convert to plain text and then display with html formatting in a web browser.

At the end of each line the symbol ¶ appears i would like to remove the symbol or replace it with a .

Does anyone know how i could do this?

This is how i convert XML to plain text:

XmlDocument doc = new XmlDocument();
                        doc.LoadXml(this.dataGridViewResult.SelectedRows[0].Cells["XMLEvent"].Value.ToString());

StringBuilder sb = new StringBuilder();
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
  sb.Append(char.ToUpper(node.Name[0]));
  sb.Append(node.Name.Substring(1));
  sb.Append(' ');
  sb.AppendLine(node.InnerText);
}
6
  • ¶ = %B6 , In case people need to know this. Commented Jun 22, 2012 at 5:49
  • @Damith Like that it does not remove the chars must i put something in the breakets ?? Commented Jun 22, 2012 at 6:01
  • var finalText = sb.ToString().Replace("¶","."); Commented Jun 22, 2012 at 6:06
  • you have several Appends, not sure where this special character adding, but you can finally remove it from the sb like above Commented Jun 22, 2012 at 6:08
  • @Damith Sadly nothing happend Commented Jun 22, 2012 at 6:09

4 Answers 4

2

Where does the '¶' appear? Is it when you open the converted text file in an editor?

Normally that sign is used to visualize the end of line in a text editor, and it's not really part of you text. In many cases you have an option in the text editor to show/hide line ending markers.

However, if the output you are interested in is HTML, the character should not appear here.

Sign up to request clarification or add additional context in comments.

2 Comments

It does not appear before i convert from XML to text so it appears somewhere in the conversion i have posed in my question.
it does not appear when i show result in a rich textbox but then my html formatting is not shown.
1

Try this:

sb.AppendLine(node.InnerText.TrimEnd('¶'));

or

sb.AppendLine(node.InnerText.Replace("¶","."));

3 Comments

@ivowiblo No sorry they did not work, the did cause some changes to my display so i don't think your far off.
Is there no way to delete it from my string.
Which is the encoding of the text in the xml and the encoding of your page?
0

After the foreach loop, Try:

sb.Replace("¶", ".");

Comments

0

Specifically in your case (assuming it's always at the end of the line), I'd use:

sb.AppendLine(node.InnerText.Replace('\u00b6', '.'));

If you want to keep your code unicode free.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.