0

I want to read data(string) present in between body tag like below -

<body> Text to read </body>

How can I do it without using HtmlAgilityPack? Please help. Thank you.

Adrian Wragg
  • 7,311
  • 3
  • 26
  • 50
ShaileshDev
  • 1,086
  • 13
  • 16

1 Answers1

0

I've got solution and without using HtmlAgilityPack and string function.I've used Regex. It's as follows-

        string html = "<body>Text to read </body>";

        RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Singleline;
        Regex regx = new Regex("<body>(?<theBody>.*)</body>", options);

        Match match = regx.Match(html);

        if (match.Success)
        {
            string theBody = match.Groups["theBody"].Value;
            //Here I'm getting all the data present in body tag              

        }
ShaileshDev
  • 1,086
  • 13
  • 16