HTML Parser on Xamarin

2

I'm developing an application with Xamarin in order to log in to a web account using HTTPWebRequest and filter relevant site information for an application.

I have already developed the login part, now I need to filter the HTML that I have returned.

I need to extract the information contained in the twelfth tag <table> of HTML, would anyone know how to do this?

The biggest difficulty I have is that tags does not have ID so I can not use that.

The html code of the page I put here for anyone who wants to copy and help me. this html is returned in the response string.

http://notepad.cc/share/hvptGOlmZQ

I need the information YYYY and XXXX contained in the tables of html ..

    
asked by anonymous 27.04.2015 / 22:54

1 answer

1

According to Data Extraction in Mobile Apps , the Html Agility Pack can be used to do this.

  

HtmlAgilityPack allows you to parse HTML documents. Instead   of traditional XML parsers, it is able to recover from   poorly written content, much like your web browser. Beyond   In addition, the library is mainly multi-platform, so it is   easy to create your furniture designs with Xamarin [...]

Assuming the foo.html file contains 20 tables and you want to select only the tenth second , query using //table[12]/tbody/tr/td//text() . Here is an example:

// using HtmlAgilityPack;

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load("arquivoHTML.html");
foreach (HtmlAgilityPack.HtmlNode nodo in 
   doc.DocumentNode.SelectNodes("//table[2]/tbody/tr/td//text()")) {
       MessageBox.Show(nodo.InnerText);
}
    
28.04.2015 / 02:26