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 6387667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:10:49+00:00 2026-05-25T03:10:49+00:00

I have the below code to parse an section of an html page. What

  • 0

I have the below code to parse an section of an html page.

What I would like to know is how to output it to either a listbox or text box.

Whenever I try I get unhandled exceltion error

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{

var doc = new HtmlDocument();
doc.LoadHtml("http://www.sourceURL.com");

var node = doc.DocumentNode.Descendants("div").FirstOrDefault(x => x.Id == "FlightInfo_FlightInfoUpdatePanel");

 var value = node.InnerHtml;
 this.textBox1.Text = value;

Exception error is :

System.NullReferenceException was unhandled
Message: NullReferenceException

Stack trace is:

   at Auckland_Airport.MainPage.PhoneApplicationPage_Loaded(Object sender, RoutedEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

HTML Layout is

        <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><tr class="alt"><td class="airline"><img src="/images/airline logos/NZ.gif" title="AIR NEW ZEALAND LIMITED. " alt="AIR NEW ZEALAND LIMITED. " /></td><td class="flight">NZ6</td><td class="codeshare">&nbsp;</td><td class="origin">Los Angeles</td><td class="date">02 Sep</td><td class="time">19:15</td><td class="est">19:15</td><td class="status">DEPARTED</td></tr><tr class=""><td class="airline"><img src="/images/airline logos/AC.gif" title="Air Canada. " alt="Air Canada. " /></td><td class="flight">AC6093</td><td class="codeshare">NZ6</td><td class="origin">Los Angeles</td><td class="date">02 Sep</td><td class="time">19:15</td><td class="est">19:15</td><td class="status">DEPARTED</td></tr><tr class="alt"><td class="airline"><img src="/images/airline  class="d
    </div>
</div>

Clearer HTML

<div id="FlightInfo_FlightInfoUpdatePanel">

   <table cellspacing="0" cellpadding="0"><tbody>
     <tr class="">
     <td class="airline"><img src="/images/airline logos/NZ.gif" title="AIR NEW ZEALAND LIMITED. " alt="AIR NEW ZEALAND LIMITED. " /></td>
     <td class="flight">NZ8</td>
     <td class="codeshare">&nbsp;</td>
     <td class="origin">San Francisco</td>
     <td class="date">01 Sep</td>
     <td class="time">17:15</td>
     <td class="est">18:00</td>
     <td class="status">DEPARTED</td>
     </tr>
     <tr class="alt">
     <td class="airline"><img src="/images/airline logos/AC.gif" title="Air Canada. " alt="Air Canada. " /></td>
     <td class="flight">AC6103</td>
     <td class="codeshare">NZ8</td>
     <td class="origin">San Francisco</td>
     <td class="date">01 Sep</td>
     <td class="time">17:15</td>
     <td class="est">18:00</td>
  • 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-25T03:10:51+00:00Added an answer on May 25, 2026 at 3:10 am

    HtmlDocument.Load function doesn’t take a Uri as a paramter, it should recieve a structured HTML, that you have somehow retrieved from a server.

    Here is the code for your case using the WebClient class to retrieve the HTML from server:

            WebClient client = new WebClient();
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    
            client.DownloadStringAsync(new Uri(@"http://www.aucklandairport.co.nz/en/FlightInformation/DomesticArrivalsAndDepartures.aspx"));
    
        }
    
        void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            var html = e.Result;
    
            var doc = new HtmlDocument();
                doc.LoadHtml(html);
    
            var list = doc.DocumentNode.Descendants("div").ToList();
    
            var node = doc.DocumentNode.Descendants("div").FirstOrDefault(x => x.Id == "FlightInfo_FlightInfoUpdatePanel");
    
            var value = string.Empty;
    
            if (node != null)
                value = node.InnerHtml;
        }
    

    At the end, the value variable holds the inner HTML you need to further parse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have below code behind in c# if (Session[cmpDictionaryTitle]!= null) { downloadLinks.Text += @<li><a
I have below html code in my aspx. <input type=hidden id=medicalLink value='<a href=/forms/contactus.aspx >Contact
I have the below code for my a Dialog box for a which contains
Hi I have below pseudo code with throws an exception like this throw new
I have the code below. The line string content = twitterMsg.text; is creating the
I have the code below which links to a page called deletepage.php which is
I have the code below that is supposed to parse an XML document. I'm
I have below code to insert a style into DOM (there is a use
I have below XAML code : <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml DataContext={Binding RelativeSource={RelativeSource Self}} WindowStartupLocation=CenterScreen

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.