I have a RTE and some content in it.ex let us take that i have two paragraphs. What i want is to extract only part of the content from RTE.i.e first pharagraph alone. can it be done?
var content=Model.GetProperty("RTE Alias").Value; <p >@Html.Raw(content)</p> This code returns me the entire content from RTE.
You should use the HtmlAgilityPack to do such operations on the html.
For example:
var html = new HtmlDocument(); html.LoadHtml(htmlContent); // htmlContent = value of the RTE property var paragraphs = html.DocumentNode.SelectNodes("//p");
Thanks for the reply and i am getting an error "Type or namespace HtmlDocument not found". I added System.Windows.Forms namespace. Am i right or should i add any other namespace.
Extracting part of content from RichText Editor
Hi All,
I have a RTE and some content in it.ex let us take that i have two paragraphs. What i want is to extract only part of the content from RTE.i.e first pharagraph alone. can it be done?
var content=Model.GetProperty("RTE Alias").Value;
<p >@Html.Raw(content)</p>
This code returns me the entire content from RTE.
Any suggestions please.Thanks in Advance
Thanks
yogesh
You should use the HtmlAgilityPack to do such operations on the html.
For example:
Cheers,
/Dirk
Hi Dirk,
Thanks for the reply and i am getting an error "Type or namespace HtmlDocument not found". I added System.Windows.Forms namespace. Am i right or should i add any other namespace.
Thanks
yogesh
Yup, you need to add
@using HtmlAgilityPack;
otherwise HtmlDocument won't be recognized.
/Dirk
Thanks dirk , i got it
is working on a reply...