0

I have a richtext box with the following content

"Amazing grace, How sweet the sound

That saved a wretch like me.

I once was lost, but now am found,

Was blind, but now I see.

//empty space - meaning 2nd para//

'Twas grace that taught my heart to fear,

And grace my fears relieved.

How precious did that grace appear

The hour I first believed."

The content is saved in the Access db as below:

Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve" TextAlignment="Left" 

LineHeight="Auto".......>

Paragraph FontFamily="Times New Roman" FontSize="16" Margin="0,6.67,0,6.67">Span>Run>Amazing grace, How sweet the 

sound/Run>/Span>Span>LineBreak />/Span>Span>Run>That saved a wretch like me./Run>/Span>Span>LineBreak 

/>/Span>Span>Run>I once was lost, but now am found, /Run>/Span>Span>LineBreak />/Span>Run>Was blind, but now I 

see./Run>/Paragraph>

Paragraph FontFamily="Times New Roman" FontSize="16" Margin="0,6.67,0,6.67">Run>/Run>/Paragraph>

Paragraph FontFamily="Times New Roman" FontSize="16" Margin="0,6.67,0,6.67">Run>'Twas grace that taught my heart to fear, 

/Run>Span>LineBreak />/Span>Span>Run>And grace my fears relieved./Run>/Span>Span>LineBreak />/Span>Span>Run>How 

precious did that grace appear/Run>/Span>Span>LineBreak />/Span>Run>The hour I first believed./Run>/Paragraph>

/Section>

Requirement: is to split the content based on paragraph and put it in two richtext boxes.

Ex: Richtexbox1 will have

Amazing grace, How sweet the sound

That saved a wretch like me.

I once was lost, but now am found,

Was blind, but now I see.

Richtextbox2 will have

Twas grace that taught my heart to fear,

And grace my fears relieved.

How precious did that grace appear

The hour I first believed.

Question: Can somebody please help with the effective way to split the richtext box contents.?

Solution: I achieved to do this by reading each blocks in the richtextbox document; then finding the block with empty text; splitting the content and putting in a new flowdocument for the new richtextbox . But still want to know if there is any other effective solution?

Angel Stephen
  • 11
  • 2
  • 5

1 Answers1

0

You're reading RichText out of an access database, and pushing it into a RichText box in WPF.

To answer your question, I would say that you could use a HTML parser, see: https://softwarerecs.stackexchange.com/questions/10773/c-library-for-parsing-html

Whatever you do, don't use regular expressions, as that way leads to madness, as evidenced by the most popular post on StackOverflow: RegEx match open tags except XHTML self-contained tags

Community
  • 1
  • 1
Contango
  • 76,540
  • 58
  • 260
  • 305