Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:56:00+00:00 2026-05-25T10:56:00+00:00

Am trying to parse this HTML document to get the contents of flight, time,

  • 0

Am trying to parse this HTML document to get the contents of flight, time, origin, date and output.

<div id="FlightInfo_FlightInfoUpdatePanel">

<table cellspacing="0" cellpadding="0">
<tbody>
    <tr class="">
    <td class="airline"><img src="/images/airline logos/US.gif" title="US AIRWAYS. " alt="US AIRWAYS. " /></td>
    <td class="flight">US5316</td>
    <td class="codeshare">NZ46</td>
    <td class="origin">Rarotonga</td>
    <td class="date">02 Sep</td>
    <td class="time">10:30</td>
    <td class="est">21:30</td>
    <td class="status">CHECK IN CLOSING</td>
    </tr>

I am using this code, based on HTML Agility Pack for windows phone 7 to find and output the content of <td class="flight">US5316</td>

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    var html = e.Result;

    var doc = new HtmlDocument();
    doc.LoadHtml(html);


    var node = doc.DocumentNode.Descendants("div")
        .FirstOrDefault(x => x.Id == "FlightInfo_FlightInfoUpdatePanel")
        .Element("table")
        .Element("tbody")
        .Elements("tr")
        .Where(tr => tr.GetAttributeValue("td", "").Contains("class"))
        .SelectMany(tr => tr.Descendants("flight"))
        .ToArray();

    this.scrollViewer1.Content = node;  

   //Added below

   listBox1.itemSource = node;
}

I get no results in either the ScrollViewer or the Listbox. I would like to know if the linq parse that I am using is correct for the HTML I supplied?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:56:01+00:00Added an answer on May 25, 2026 at 10:56 am

    What do you intend to do with this line?

    .Where(tr => tr.GetAttributeValue("td", "").Contains("class"))
    

    GetAttributeValue(name, def) looks for an attribute with the key name in the node, and it returns the value of that attribute in case it founds it. Otherwise, it returns the default value def.

    So what’s actually happening here is that <tr> doesn’t have any attribute with the key td, so it’s returning the default value (an empty string), which does not contain the substring “class”, so your <tr> node is being filtered out.

    Edit:
    This will return an array where each entry is an array of 8 strings containing the contents of each td:

    var node = doc.DocumentNode.Descendants("div")
        .FirstOrDefault(x => x.Id == "FlightInfo_FlightInfoUpdatePanel")
        .Element("table")
        .Element("tbody")
        .Elements("tr")
        .Select(tr => tr.Elements("td").Select(td => td.InnerText).ToArray())
        .ToArray();
    

    Examples:

    node[0][1] == "US5316"
    node[0][3] == "Rarotonga"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use preg_replace function to parse this table in a Html
I'm trying to parse an html document with Jsoup to get all heading tags.
I'm trying to parse a html doc using some code I found from this
I'm trying to parse this XML I want to get a list of all
I'm trying to parse an HTML document for a web indexing program. To do
I have this xpath expression that does not work //div[child[0]::h4[text()[contains(.,'Dir')]]]/a To parse this html:
I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
I'm trying to parse this JSOn with multiple entries of node tag: { nodes:
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I'm trying to parse 3 arguments (this works) and request a file that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.