Hi All,
I want parse the JSON data using HtmlAgilityPack. Below is JSON data and I would like to capture company_url from the json data. I am using Xpath as //startups/id/company_url but not able to extract the company url. I am providing the piece of code also.
{"startups":[
{"id":233756,"hidden":true},
{"id":233734,"hidden":true},
{"id":232400,"hidden":true},
{"id":231849,"hidden":true},
{"id":228193,"hidden":false,"community_profile":false,"name":"Natural eCommerce","angellist_url":"https://angel.co/natural-ecommerce","logo_url":"https://angel.co/images/shared/nopic_startup.png","thumb_url":"https://angel.co/images/shared/nopic_startup.png","quality":1,"product_desc":"Natural eCommerce uses Drupal Commerce to market and distribute the goods of companies and individual creators. Our first site to launch sells the best cheese on the Internet - raw, organic cheese from Welsh Mountain Farm in Lancaster County, PA.\n\nhttp://www.realmilkcheese.com","high_concept":"Online distributor for natural living product companies and individual creators.","follower_count":2,"company_url":"http://www.realmilkcheese.com","created_at":"2013-06-28T02:16:28Z","updated_at":"2013-06-28T02:25:21Z","twitter_url":"","blog_url":"","video_url":"","markets":[{"id":29,"tag_type":"MarketTag","name":"e-commerce","display_name":"E-Commerce","angellist_url":"https://angel.co/e-commerce"},{"id":1445,"tag_type":"MarketTag","name":"specialty foods","display_name":"Specialty Foods","angellist_url":"https://angel.co/specialty-foods"},{"id":2637,"tag_type":"MarketTag","name":"organic food","display_name":"Organic Food","angellist_url":"https://angel.co/organic-food"}],"locations":[{"id":1654,"tag_type":"LocationTag","name":"louisville","display_name":"Louisville","angellist_url":"https://angel.co/louisville"}],"crunchbase_url":null,"company_type":[{"id":94212,"tag_type":"CompanyTypeTag","name":"startup","display_name":"Startup","angellist_url":"https://angel.co/startup"}],"status":null,"screenshots":[{"thumb":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/5ec882148bc9d06892873df6563a6f39-thumb_jpg.jpg","original":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/5ec882148bc9d06892873df6563a6f39-original.jpg"},{"thumb":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/a0916a2d75bb99c018dcca9cbd1cae52-thumb_jpg.jpg","original":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/a0916a2d75bb99c018dcca9cbd1cae52-original.jpg"},{"thumb":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/d64217dc93f66267ccee6a814c2e3de8-thumb_jpg.jpg","original":"https://s3.amazonaws.com/screenshots.angel.co/c1/228193/d64217dc93f66267ccee6a814c2e3de8-original.jpg"}]}]}
C# Code
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestLink);
var response = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var objText = reader.ReadToEnd();
// Read into a HTML store read for HAP
htmlDoc.LoadHtml(objText);
HtmlNodeCollection tl = htmlDoc.DocumentNode.SelectNodes(@"/startups/id/");
foreach (HtmlAgilityPack.HtmlNode node in tl)
{
System.Console.WriteLine(node.company_url);
}
Can anyone help me how to extract the company url from json object