This is a migrated thread and some comments may be shown as answers.

[Solved] Does it work in RadRickTextBox using XML+CSS

3 Answers 96 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
walter
Top achievements
Rank 1
walter asked on 03 Aug 2011, 09:30 AM
Hi all,
        I want to use RadRichTextBox to handle an xml data, and display the style with using CSS, does it work? And I see that there is a RadDocument class handles all the input format, can I get the Attribute of the XML input at the RadDocument? Such as:
xml:
<header ID="01">Hello World</header>

Can I get the code "01" when using RadDocument?

3 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 08 Aug 2011, 08:07 AM
Hi Walter,

Directly importing XML using RadRichTextBox is not possible due to the fact that XML describes neither content layout nor formatting. Of course, you can import the XML source as plain text and view the source XML in the editor. However, if this is done, there is no way to apply CSS formatting. The recommended way to handle such cases is either to generate a RadDocument from your source with the proper formatting using the API, or, if it's easier for you - generate XHTML+CSS from the XML and import that using HtmlFormatProvider.

Best wishes,
Ivailo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
walter
Top achievements
Rank 1
answered on 08 Aug 2011, 09:08 AM
Hi sir,
        How can I get the comments from RadDocument those I have added to, and do you mean XHTML and CSS in one file and import to RadDocument?
0
Iva Toteva
Telerik team
answered on 11 Aug 2011, 10:07 AM
Hi Walter,

Comments have a Body property that is of type RadDocument. On the other hand, the place in the document which is commented is marked with CommentRangeStart and CommentRangeEnd.
You can get all comments in the following way:

List<string> commentTexts = new List<string>();
TxtFormatProvider txtFormatProvider = new TxtFormatProvider();
foreach (var comment in this.editor.Document.EnumerateChildrenOfType<CommentRangeStart>())
{
    RadDocument currentCommentBody = ((CommentRangeEnd)comment.End).Comment.Body;
    commentTexts.Add(txtFormatProvider.Export(currentCommentBody));
}

As for the import question, yes, HtmlFormatProvider is able to import and export XHTML documents with CSS styles in the same file. You can preview the import and export in our online demos.


Best wishes,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
RichTextBox
Asked by
walter
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
walter
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or