All Projects → StefH → XPath2.Net

StefH / XPath2.Net

Licence: MS-PL License
Lightweight XPath2 for .NET

Programming Languages

HTML
75241 projects
C#
18002 projects

Projects that are alternatives of or similar to XPath2.Net

Xqerl
Erlang XQuery 3.1 Processor
Stars: ✭ 44 (+69.23%)
Mutual labels:  xml, xpath
Xquery
Extract data or evaluate value from HTML/XML documents using XPath
Stars: ✭ 155 (+496.15%)
Mutual labels:  xml, xpath
Internettools
XPath/XQuery 3.1 interpreter for Pascal with compatibility modes for XPath 2.0/XQuery 1.0/3.0, custom and JSONiq extensions, XML/HTML parsers and classes for HTTP/S requests
Stars: ✭ 82 (+215.38%)
Mutual labels:  xml, xpath
Amazon Mobile Sentiment Analysis
Opinion mining of Mobile reviews on Amazon platform
Stars: ✭ 19 (-26.92%)
Mutual labels:  xml, xpath
Ono
A sensible way to deal with XML & HTML for iOS & macOS
Stars: ✭ 2,599 (+9896.15%)
Mutual labels:  xml, xpath
Xml
XML without worries
Stars: ✭ 35 (+34.62%)
Mutual labels:  xml, xpath
Graphquery
GraphQuery is a query language and execution engine tied to any backend service.
Stars: ✭ 112 (+330.77%)
Mutual labels:  xml, xpath
Basex
BaseX Main Repository.
Stars: ✭ 515 (+1880.77%)
Mutual labels:  xml, xpath
Pugixml
Light-weight, simple and fast XML parser for C++ with XPath support
Stars: ✭ 2,809 (+10703.85%)
Mutual labels:  xml, xpath
Xmlquery
xmlquery is Golang XPath package for XML query.
Stars: ✭ 209 (+703.85%)
Mutual labels:  xml, xpath
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+3338.46%)
Mutual labels:  xml, xpath
xpath2.js
xpath.js - Open source XPath 2.0 implementation in JavaScript (DOM agnostic)
Stars: ✭ 74 (+184.62%)
Mutual labels:  xpath, xpath2
Sirix
SirixDB is a temporal, evolutionary database system, which uses an accumulate only approach. It keeps the full history of each resource. Every commit stores a space-efficient snapshot through structural sharing. It is log-structured and never overwrites data. SirixDB uses a novel page-level versioning approach called sliding snapshot.
Stars: ✭ 638 (+2353.85%)
Mutual labels:  xml, xpath
Xom
XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with Java that strives for correctness, simplicity, and performance, in that order.
Stars: ✭ 38 (+46.15%)
Mutual labels:  xml, xpath
Parsel
Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
Stars: ✭ 628 (+2315.38%)
Mutual labels:  xml, xpath
Markup
A Swift package for working with HTML, XML, and other markup languages, based on libxml2.
Stars: ✭ 93 (+257.69%)
Mutual labels:  xml, xpath
Xpath
XPath package for Golang, supports HTML, XML, JSON document query.
Stars: ✭ 376 (+1346.15%)
Mutual labels:  xml, xpath
Camaro
camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.
Stars: ✭ 438 (+1584.62%)
Mutual labels:  xml, xpath
Jquery Xpath
jQuery XPath plugin (with full XPath 2.0 language support)
Stars: ✭ 173 (+565.38%)
Mutual labels:  xml, xpath
Meeseeks
An Elixir library for parsing and extracting data from HTML and XML with CSS or XPath selectors.
Stars: ✭ 252 (+869.23%)
Mutual labels:  xml, xpath

XPath2.Net : Lightweight XPath2 for .NET

This is an implementation of W3C XML Path Language (XPath) 2.0 for .NET Framework based on standard XPathNavigator API. The given implementation based on practice of developing XQuery is fully corresponding to the specification demands.

Project is copied and forked from https://xpath2.codeplex.com/. Original credits go to Semyon A. Chertkov.

Build

Quality  
  Build Azure Build Status
  CodeFactor CodeFactor
  Sonar Quality Gate Sonar Quality Gate
  Sonar Bugs Sonar Bugs
  Sonar Code Smells Sonar Code Smells
  Sonar Coverage Sonar Coverage
NuGet  
  XPath2 NuGet Badge
  XPath2.Extensions NuGet Badge
MyGet (previews)  
  XPath2 MyGet
  XPath2.Extensions MyGet

Supported frameworks

  • .NET 3.5
  • .NET 4.0 and up
  • .NET Standard 2.0 & 2.1
  • Mono 4 and up

Info

It conforms for 12954 * from 15133 (85.60%) regarding the test-set XQTSCatalog.xml (XQTS 1.0.2 Nov. 20, 2006) at https://dev.w3.org/2006/xquery-test-suite/PublicPagesStagingArea/

* Note that depending on your system, you can get 12958 to work. This is because of some tests which test the lowercase functionality from 'K' (Kelvin-sign). More details see this question.

API used is an anology to the standard one built into the platform: you utilize XPath2Expression instead of the common XPathExpression and a set of extension functions for XNode, XPathNavigator and XmlNode classes.

System.Xml.XPath WmHelp.XPath2
XPathNavigator.Evaluate() XPathNavigator.XPath2Evaluate()
XmlNode.SelectNodes() XmlNode.XPath2SelectNodes()
XmlNode.SelectSingleNode() XmlNode.XPath2SelectSingleNode()
XNode.Select() XNode.XPath2Select()
..., etc. ..., etc.

In addition there parameterized XPath2 expressions are implemented that allow to compose XQuery requests by standard Linq-to-XML means. Though it is not generally necessary to use XPath during writing Linq-to-XML queries nevertheless they allow to make it simple. To pass variable values into XPath expression we use C# 4.0 anonimous structures, e.g. new { varname = value, ... } creates variable $varname,... inside XPath expression.

Here are examples of some W3C XQuery usecases and their translations into C# and LINQ.

XQuery (RQ2.xq)

<result>
  {
    for $i in doc("items.xml")//item_tuple
    let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno]
    where contains($i/description, "Bicycle")
    order by $i/itemno
    return
        <item_tuple>
            { $i/itemno }
            { $i/description }
            <high_bid>{ max($b/bid) }</high_bid>
        </item_tuple>
  }
</result> 

C#

XNode items = XDocument.Load("items.xml");
XNode bids = XDocument.Load("bids.xml");
XNode result = new XDocument(
    new XElement("result",
        (from item in items.XPath2SelectElements("//item_tuple")
                .OrderBy((elem) => (string)elem.Element("itemno"))                       
            let bid = bids.XPath2Select<XElement>("//bid_tuple[itemno = $i/itemno]", new { i = item })
            where ((string)item.Element("description")).Contains("Bicycle")
            select new XElement("item_tuple", 
                item.Element("itemno"),
                item.Element("description"),
                !bid.Any() ?  null :
                    new XElement("high_bid", 
                        bid.AsQueryable().Max((elem) => (double)elem.Element("bid"))))))
);

XQuery (RQ3.xq)

<result>
  {
    for $u in doc("users.xml")//user_tuple
    for $i in doc("items.xml")//item_tuple
    where $u/rating > "C" 
       and $i/reserve_price > 1000 
       and $i/offered_by = $u/userid
    return
        <warning>
            { $u/name }
            { $u/rating }
            { $i/description }
            { $i/reserve_price }
        </warning>
  }
</result>

C#

XNode users = XDocument.Load("users.xml");
XNode items = XDocument.Load("items.xml");
XNode result = 
    new XElement("result",
        (from user in users.XPath2SelectElements("//user_tuple")
            from item in items.XPath2SelectElements("//item_tuple")
            where (bool)XPath2Expression.Evaluate(@"$u/rating > 'C' and $i/reserve_price > 1000 
                    and $i/offered_by = $u/userid", new { u = user, i = item })
            select new XElement("warning",
                user.Element("name"),
                user.Element("rating"),
                item.Element("description"),
                item.Element("reserve_price"))));

XQuery (RQ9.xq)

<result>
  {
    let $end_dates := doc("items.xml")//item_tuple/end_date
    for $m in distinct-values(for $e in $end_dates 
                              return month-from-date($e))
    let $item := doc("items.xml")
        //item_tuple[year-from-date(end_date) = 1999 
                     and month-from-date(end_date) = $m]
    order by $m
    return
        <monthly_result>
            <month>{ $m }</month>
            <item_count>{ count($item) }</item_count>
        </monthly_result>
  }
</result>

C#

XNode items = XDocument.Load("items.xml");
var endDates = items.XPath2SelectElements("//item_tuple/end_date");
XNode result = 
    new XElement("result",
        (from month in XPath2Expression.SelectValues(@"distinct-values(for $e in $end_dates 
                    return month-from-date($e))", new { end_dates = endDates }).OrderBy((arg) => arg)
            let item = items.XPath2SelectElements(@"//item_tuple[year-from-date(end_date) = 1999 
                    and month-from-date(end_date) = $m]", new { m = month })
            select new XElement("monthly_result",
                new XElement("month", month),
                new XElement("item_count", item.Count())
            )));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].