0

First of all I am fairly new to this so please forgive me if I am asking a noobish question. I am using Xamarin Forms and trying to get some table data from a webpage. This is my current code block:

private async Task GetTheData()
{
    try
    {
        string requestUrl = "http://www.ahpra.gov.au/Registration/Registers-of-Practitioners.aspx?reg=NMW0001317068";
        HttpClient client = new HttpClient();
        var response = await client.GetStreamAsync(requestUrl);
        StreamReader streamReader = new StreamReader(response);
        string contentResponse = streamReader.ReadToEnd();
        var obj = JsonConvert.DeserializeObject(contentResponse);
        Debug.WriteLine(obj);
    }
    catch(Exception ex)
    {
        Debug.WriteLine(ex.Message);
    }
}

The exception gives me the log:

[0:] Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

I am trying to get the data from the page and pull it out. I have been trying to do some research but can't seem to find any information on how to pull the data from an .aspx page.

Thanks in advance.

Poodle Galluzzo
  • 79
  • 1
  • 10
  • You're most likely getting an HTML page back, which you can't use DeserializeObject on. You _might_ be able to use something like [Html Agility Pack](https://htmlagilitypack.codeplex.com/), or [AngleSharp](https://anglesharp.github.io/). – Tieson T. Apr 09 '17 at 05:50
  • It seems url is not returninh json,which causing deserialization error. – Anupam Singh Apr 09 '17 at 05:51

1 Answers1

0

Go through this link....
Pulling data from a webpage, parsing it for specific pieces, and displaying it
hope you resolve problem.........

Community
  • 1
  • 1
Sudhakar singh
  • 104
  • 2
  • 9
  • Hey thanks for the reply. After some research this looks like what I need. I am still having some troubles though. I followed the example in the link you provided but I keep getting an error saying "HtmlNode" does not contain a definition for "SelectNodes". Any ideas? – Poodle Galluzzo Apr 09 '17 at 11:48
  • Follow this url: http://stackoverflow.com/questions/27766242/htmlagilitypack-htmlnode-no-definition-for-selectnodes – Sudhakar singh Apr 09 '17 at 15:21