Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julian-eggers/xpath-helper
XPath helpers based on Xom
https://github.com/julian-eggers/xpath-helper
java xml xml-parser xom xpath
Last synced: 11 days ago
JSON representation
XPath helpers based on Xom
- Host: GitHub
- URL: https://github.com/julian-eggers/xpath-helper
- Owner: julian-eggers
- License: mit
- Created: 2015-04-17T21:02:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-02T04:15:24.000Z (over 3 years ago)
- Last Synced: 2024-10-10T05:37:11.123Z (28 days ago)
- Topics: java, xml, xml-parser, xom, xpath
- Language: Java
- Homepage:
- Size: 123 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
xpath-helper
============[![Maven Central](https://img.shields.io/maven-metadata/v/http/central.maven.org/maven2/com/itelg/xpath-helper/maven-metadata.xml.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.itelg%22%20AND%20a%3A%22xpath-helper%22)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/d69f266924be4b68ba7fb24cb3d49c15)](https://www.codacy.com/app/eggers-julian/xpath-helper)
[![Coverage Status](https://coveralls.io/repos/julian-eggers/xpath-helper/badge.svg)](https://coveralls.io/r/julian-eggers/xpath-helper)
[![Build Status](https://travis-ci.org/julian-eggers/xpath-helper.svg?branch=master)](https://travis-ci.org/julian-eggers/xpath-helper)XPath helpers based on [XOM](http://www.xom.nu/ "XOM")
#### Maven
```xmlcom.itelg
xpath-helper
0.6.0```
#### Supported methods
```java
getNodes() : Nodes
getNodeList() : List
hasNodes() : boolean
hasNode() : boolean
getFirstNode() : Node
getFirstElement() : Element
getLastNode() : Node
getLastElement() : Element
getString() : String
getNullableString() : String
getDouble() : Double
getPDouble() : double
getInteger() : Integer
getInt() : int
getLong() : Long
getPLong() : long
getBoolean() : Boolean
getBool() : boolean
getZonedDateTime() : ZonedDateTime
getLocalDateTime() : LocalDateTime
getLocalDate() : LocalDate
getEnum() : Enum
```#### AbstractParser-Example
```java
public static void main(String[] args) throws Exception
{
String xml = "Test"
+ "1.12"
+ "VALUE";
TestClass testClass = new TestParser().parse(xml);
System.out.println(testClass);
}public static class TestParser extends AbstractParser
{
@Override
protected TestClass doParse(Element rootElement) throws Exception
{
TestClass test = new TestClass();
test.stringValue = XPathHelper.getString("stringValue", rootElement);
test.doubleValue = XPathHelper.getDouble("doubleValue", rootElement);
test.testEnum = XPathHelper.getEnum("testEnum", TestClass.TestEnum.class, rootElement);
return test;
}
}public static class TestClass
{
private String stringValue;
private Double doubleValue;
private TestEnum testEnum;
@Override
public String toString()
{
return "TestClass [stringValue=" + stringValue + ", doubleValue=" + doubleValue + ", testEnum=" + testEnum + "]";
}private enum TestEnum
{
VALUE;
}
}
```#### Plain-Example
```java
public static void main(String[] args) throws Exception
{
String xml = "Test"
+ "1.12";
Element rootElement = DocumentHelper.getRootElement(xml);
System.out.println(XPathHelper.getString("stringValue", rootElement));
System.out.println(XPathHelper.getDouble("doubleValue", rootElement));
}
```## Build & Release
### Build
```
mvn clean package
```### Release
```
mvn clean deploy
```