Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • yogesh 7 posts 67 karma points
    May 15, 2013 @ 10:56
    yogesh
    0

    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

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 15, 2013 @ 11:07
    Dirk De Grave
    100

    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"); 

    Cheers,

    /Dirk

  • yogesh 7 posts 67 karma points
    May 15, 2013 @ 11:46
    yogesh
    0

    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

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 15, 2013 @ 11:48
    Dirk De Grave
    0

    Yup, you need to add

    @using HtmlAgilityPack;

    otherwise HtmlDocument won't be recognized.

     

    /Dirk

  • yogesh 7 posts 67 karma points
    May 15, 2013 @ 15:27
    yogesh
    0

    Thanks dirk , i got it

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies