c# - HTML Agility Pack Usage on WP8 -


this question follow on earlier question posted here parsing html read html on windows phone 8

i parsing html page has ton of tr tags this:

<tr>         <td class="first">          </td>         <td >             origin         </td>         <td>               airline         </td>         <td>             flight number         </td>         <td>             22 feb 11:50         </td>         <td class="last">             arrived 12:35         </td> </tr> 

this code using read page , it's working fine:

foreach (htmlnode node in htmldocument.documentnode.selectnodes("//td")) {     string item = node.childnodes[0].innerhtml.trim();     lstresults.items.add(item) } 

the problem is, want concatenate each group of 5 td values 1 string. @ moment, code adding each item individually lisbox, 5 entries per flight this:

flightnumber duetime arrival time origin airline 

but instead want add 1 entry per flight, this:

origin - airline - flight number - due - arrived

there tr tag each flight , inside each tr tag information shown above. i'm not sure how detect when reach end of tag particular flight can group information 1 string, rather adding each td tag individually. there blank string @ start or end of each tr tag, again can't work out how concatenate values per td tag 1 string, rather adding each value on seperate line.

any ideas?

i got working using implementation below.

htmlnodecollection table = htmldocument.documentnode.selectnodes("//tr");  htmlnodecollection rows = table[0].selectnodes("//td");  (int = 0; < rows.count; ++i) {     string flight = rows[i].innerhtml.trim();      if (!flight.contains(".jpg"))     {         item += flight + " - ";     }     else     {         lstflights.items.add(item);         item = "";     }  } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -