Using HTML Agility Pack in windows phone 7

308 Views Asked by At

How can I get text in p tag behind from body tag with using Linq with HtmlAgilitypack? Iam not sure that people say htmlagility doesn't support xpath. I will parse html codes.

1

There are 1 best solutions below

1
On

Simplest way to use HtmlAgility ->

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

doc.LoadHtml(string);   //string contains the html code

var paragraphTags = doc.DocumentNode.SelectNodes("p"); //selects all p tags

for (int i = 0; i < paragraphTags.Count; i++)   //loop through the p tags
{
    String text = paragraphTags[i].InnerHtml;
    //text has your paragraph content. use it here.
}