How to get div tag values from innerHtmlText? in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anwarulhaque
    New Member
    • Sep 2006
    • 1

    How to get div tag values from innerHtmlText? in C#

    My Question is .
    Code:
    [B]String varText ="<div>
    <h3> Title </h3>
    <p>body text details </p>
    Venue : india  Time : 12:10:10 am
    </div>";[/B]
    
    
    Now I need to do here extracting values and store on diffrent variable
    from "varText" data extract as a below format!
    String Title = <h3> Title </h3>
    String body = <p>body text details </p>
    String venue = Venue : india  
    String Time = Time : 12:10:10 am
    Any body help me!
    Thanks in Adv
    Haque
    <email removed for your own protection>
    Last edited by Frinavale; Nov 12 '08, 08:36 PM. Reason: email removed
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Instead of shoving everything into one String variable as you are doing here:
    Code:
    String varText ="<div>
    <h3> Title </h3>
    <p>body text details </p>
    Venue : india  Time : 12:10:10 am
    </div>";
    Spit it up into 3 Strings....as you are doing here:
    [code=cpp]
    String Title = "Title";
    String body = "body text details";
    String venue = "India";
    String Time = DateTime.Now();[/CODE]

    Add some Labels to your ASPX page and set their styles so that they are the way you want them to:

    Eg:
    [code=asp]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitl ed Page</title>
    </head>
    <body style="backgrou nd:White;">
    <form id="form1" runat="server">
    <h3><asp:Labe l ID="myTitleLabe l" runat="server"> </asp:Label></h3>
    <div>
    <asp:Label ID="myBodyLabel " runat="server"> </asp:Label><br />
    <asp:Label ID="myVenueLabe l" runat="server"> </asp:Label><br />
    <asp:Label ID="myTimeLabel " runat="server"> </asp:Label><br />
    </div>
    </form>
    </body>
    </html>
    [/code]

    Then set your the text in the labels:

    [code=cpp]
    myTitleLabel.Te xt=Title;
    myBodyLabel.Tex t=Body;
    myVenueLabel=Ve nue;
    myTimeLabel=Tim e;
    [/code]

    Now you have no nned to extract the innerHtmlText.. .you just grab the Strings out of the Labels' Text property.

    Although I have no idea what you are trying to do...

    Comment

    Working...