Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

finding content between specific div tags

Last post 05-11-2008, 7:30 PM by Aussie Susan. 1 replies.
Sort Posts: Previous Next
  •  05-09-2008, 2:35 PM 42088

    finding content between specific div tags

    My programming language is ASP.NET C# and HTML.

    I'm working on a program that will get the contents of a string and output the values between a specific div tag in my code.

    Here is my original text:

    <div id="claimsfooter" style='display:none;'>

    here is the text I need to get

    </div>

    Here is what I'm trying to output:

    here is the text I need to get  <--- I need to assign this text to a variable.

    The div tag will always begin with <div id="claimsfooter" style='display:none;'> and end with </div>.  I need to pull the middle piece out.
     

    Any help would be most appreciated.  

  •  05-11-2008, 7:30 PM 42112 in reply to 42088

    Re: finding content between specific div tags

    Try:

    <div\sid="claimsfooter"\sstyle='display:none;'>(.*?)</div>

    with the 'singleline' ("dot matches newline") option on. The text between the <div> tag items will be in match group #1.

    However, please be aware that (as in your example) the text will also contain any newline characters etc which you will need to strip off. It will also contain any other tags that exist between the start and the end tag. Also, if there is ANY variance in the starting tag then this won't work - this is why we really need real examples to work with.

    If this is all you want, then perhaps the HTML DOM library will be a better option. 

    Susan 

View as RSS news feed in XML