Skip to content

volodya-lombrozo/xnav

Repository files navigation

xnav

Maven Central License Hits-of-Code codecov

Xnav is a library designed for seamless navigation and querying of XML documents, inspired by the simplicity and elegance of XPath. With Xnav, developers can easily traverse and extract information from XML structures.

Installation

The library is available on Maven Central. To add it to your project, include the following snippet in your pom.xml:

<dependency>
  <groupId>com.github.volodya-lombrozo</groupId>
  <artifactId>xnav</artifactId>
  <version>0.1.18</version>
</dependency>

How to Use

Xnav provides a fluent API for navigating and querying XML. Here's a basic example of how to use it:

import com.github.lombrozo.xnav.Xnav;

public final class XnavUsage {
    public static void main(String[] args) {
        System.out.println(
            new Xnav("<root><item key='value'/></root>")
                .element("root")
                .element("item")
                .attribute("key")
                .text()
                .orElse("default")
        ); // Output: value
    }
}

Benchmarks

The library not only provides an intuitive API but also addresses performance issues that arise when using XPath on large XML files. Below is one example of how Xnav can outperform other libraries:

Library XPath Expression Execution Time (ms)
Saxon /program/@name 255.63
Jaxen /program/@name 46.57
JAXP /program/@name 75.10
Xnav .element('program').attribute('name') 2.80

You can find more benchmarks here.

Building from Source

To build the library from source, clone the repository and run the following command in the root directory:

mvn clean install

To run the tests, use the following command:

mvn test

Also, you might want to update examples in the README file. To do this, run:

mvn process-resources -Pdocs

To run benchmarks, use the following command:

mvn clean verify -Pbenchmark -DskipTests

Contribution

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the main branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request, please run full Maven build:

$ mvn clean install -Pqulice

You will need Maven 3.3+ and Java 11+ installed.

About

Library for seamless navigation and querying of XML documents

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •