Skip to content

Instantly share code, notes, and snippets.

@Atulin
Created November 9, 2018 21:17
Show Gist options
  • Save Atulin/9734d3c15d40a3bac285e8b018da4aa0 to your computer and use it in GitHub Desktop.
Save Atulin/9734d3c15d40a3bac285e8b018da4aa0 to your computer and use it in GitHub Desktop.
A short and sweet Xpath checker. Made with .NET Core
using System;
using HtmlAgilityPack;
namespace XpathStuff
{
class Program
{
static void Main(string[] args)
{
Console.Write("URL to parse: ");
string url = Console.ReadLine();
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load (url);
Console.Write("XPath to check against: ");
string xpath = Console.ReadLine();
HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(xpath);
foreach (HtmlNode node in nodes)
{
Console.WriteLine(node.InnerText);
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment