{"id":18286548,"url":"https://github.com/mntone/xpath","last_synced_at":"2025-10-30T04:30:51.925Z","repository":{"id":144198302,"uuid":"47526555","full_name":"mntone/XPath","owner":"mntone","description":"Simplified xpath function generator.","archived":false,"fork":false,"pushed_at":"2015-12-07T05:22:00.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T08:53:12.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mntone.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T03:17:57.000Z","updated_at":"2015-12-07T03:30:35.000Z","dependencies_parsed_at":"2023-03-21T19:24:18.175Z","dependency_job_id":null,"html_url":"https://github.com/mntone/XPath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mntone%2FXPath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mntone%2FXPath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mntone%2FXPath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mntone%2FXPath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mntone","download_url":"https://codeload.github.com/mntone/XPath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238930063,"owners_count":19554122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T13:20:56.974Z","updated_at":"2025-10-30T04:30:46.637Z","avatar_url":"https://github.com/mntone.png","language":"C#","readme":"# XPath\n\n[![Build status](https://img.shields.io/appveyor/ci/mntone/XPath/master.svg?style=flat-square)](https://ci.appveyor.com/project/mntone/XPath) [![NuGet](https://img.shields.io/nuget/v/Mntone.XPath.svg?style=flat-square)](https://www.nuget.org/packages/Mntone.XPath/) [![Downloads](https://img.shields.io/nuget/dt/Mntone.XPath.svg?style=flat-square)](https://www.nuget.org/packages/Mntone.XPath/) [![License](https://img.shields.io/github/license/mntone/XPath.svg?style=flat-square)](https://github.com/mntone/XPath/blob/master/LICENSE.txt)\n\nThis is simplified xpath function generator for .NET.\n\n\n## Requirement\n\n- Each parser (e.g. HtmlAgilityPack)\n\n\n## Usage\n\nIn this case, use HtmlAgilityPack together.\n\n1. Install XPath.\n2. Create class `XPathRetriveConfig.`\n\n\t```csharp\n\tinternal sealed class HtmlAgilityXPathRetriveConfig : IXPathRetriveConfig\u003cHtmlNode\u003e\n\t{\n\t\tpublic static HtmlAgilityXPathRetriveConfig Instance { get { return _Instance ?? (_Instance = new HtmlAgilityXPathRetriveConfig()); } }\n\t\tprivate static HtmlAgilityXPathRetriveConfig _Instance = null;\n\n\t\tprivate HtmlAgilityXPathRetriveConfig() { }\n\n\t\tpublic Expression\u003cFunc\u003cHtmlNode, IEnumerable\u003cHtmlNode\u003e\u003e\u003e ChildrenGetter =\u003e node =\u003e node.ChildNodes;\n\n\t\tpublic Expression\u003cFunc\u003cHtmlNode, string\u003e\u003e TagNameGetter =\u003e node =\u003e node.Name;\n\t\tpublic Expression\u003cFunc\u003cHtmlNode, string\u003e\u003e TextGetter =\u003e node =\u003e node.InnerText;\n\t\tpublic Expression\u003cFunc\u003cHtmlNode, string, string\u003e\u003e AttributeValueGetter =\u003e (node, name) =\u003e node.GetAttributeValue(name, string.Empty);\n\t}\n\t```\n\n3. Compile function and parse.\n\n\t```csharp\n\tpublic string GetFirstDivText(string html)\n\t{\n\t\tvar func = XPathExpression.Compile\u003cHtmlNode, T\u003e(\"/html/body/div[0]/text()\", HtmlAgilityXPathRetriveConfig.Instance);\n\n\t\tvar doc = new HtmlDocument();\n\t\tdoc.Load(new StringReader(html));\n\n\t\tvar result = func(new[] { doc.DocumentNode }).Single();\n\t\treturn result;\n\t}\n\t```\n\n\n## LICENSE\n\n[MIT License](https://github.com/mntone/XPath/blob/master/LICENSE.txt)\n\n\n## Author\n\n- mntone\u003cbr\u003e\n\tGitHub: https://github.com/mntone\u003cbr\u003e\n\tTwitter: https://twitter.com/mntone (posted in Japanese; however, english is ok)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmntone%2Fxpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmntone%2Fxpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmntone%2Fxpath/lists"}