xpather

Xpather is a simple DSL for generating xpath expressions, including specific support for creating xpath expression for xHtml

Лицензия

Лицензия

Группа

Группа

org.tbag
Идентификатор

Идентификатор

xpather
Последняя версия

Последняя версия

1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

xpather
Xpather is a simple DSL for generating xpath expressions, including specific support for creating xpath expression for xHtml
Ссылка на сайт

Ссылка на сайт

https://github.com/timt/xpather
Система контроля версий

Система контроля версий

https://github.com/timt/xpather.git

Скачать xpather

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.tbag/xpather/ -->
<dependency>
    <groupId>org.tbag</groupId>
    <artifactId>xpather</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.tbag/xpather/
implementation 'org.tbag:xpather:1.1'
// https://jarcasting.com/artifacts/org.tbag/xpather/
implementation ("org.tbag:xpather:1.1")
'org.tbag:xpather:jar:1.1'
<dependency org="org.tbag" name="xpather" rev="1.1">
  <artifact name="xpather" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.tbag', module='xpather', version='1.1')
)
libraryDependencies += "org.tbag" % "xpather" % "1.1"
[org.tbag/xpather "1.1"]

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.8.2
jtidy : jtidy jar 4aug2000r7-dev

Модули Проекта

Данный проект не имеет модулей.

Xpather

Xpather is a simple DSL for generating xpath expressions, including specific support for creating xpath expression for xHtml

Cookbook

  • Selecting the root node i.e. /Library
  • Select a node from the current node the document not matter where they are, i.e. /Library//Book
  • Select all the elements with a given value, i.e., //book[price='35.00']
  • Select a node with attribute, i.e. //Book/@language
  • Select a node with attribute with value, i.e. //Book[@language='english']
  • Select xHtml element with id, i.e. //div[@id='myId']
  • Select xHtml element with style class, i.e. //div[@class='myClass']
  • Select an xHtml element with an attribute that contains a value, i.e. //div[contains(@class, 'myClass')]
  • Select a repeating element at index, i.e. //div/ul/li[2]

Selecting the root node i.e. /Library

import static xpather.XpathExpression.*;
...
element("Library").toXpath();

Will return the xpath expression

/Library

Select a node from the current node the document no matter where they are, i.e. /Library//Book

import static xpather.XpathExpression.*;
...
element("Library").with(any(element("Book"))).toXpath();

Will return the xpath expression

/Library//Book

Select all the elements with a given value, i.e., //book[price='35.00']

import static xpather.XpathExpression.*;
...
any(element("book")).with(element("price").equalTo("35.00")).toXpath();

Will return the xpath expression

/Library//Book

Select a node with attribute, i.e. //Book/@language

import static xpather.XpathExpression.*;
...
any(element("Book")).with(attribute("language")).toXpath();

Will return the xpath expression

//Book/@language

Select a node with attribute with value, i.e. //Book[@language='english']

import static xpather.XpathExpression.*;
...
any(element("Book")).with(attribute("language").containing("english")).toXpath();

Will return the xpath expression

//Book[@language='english']

Select xHtml element with id, i.e. //div[@id='myId']

import static xpather.XpathExpression.*;
...
any(div().with(id("myId"))).toXpath();

Will return the xpath expression //div[@id='myId']

Select xHtml element with style class, i.e. //div[@class='myClass']

import static xpather.XpathExpression.*;
...
any(div().with(css("myClass"))).toXpath();

Will return the xpath expression

//div[@class='myClass']

Select an xHtml element with an attribute that contains a value, i.e. //div[contains(@class, 'myClass')]

import static xpather.XpathExpression.*;
...
any(div().with(css(containing("myClass")))).toXpath();

Will return the xpath expression

//div[contains(@class, 'myClass')]

Select a repeating element at index, i.e. //div/ul/li[2]

import static xpather.XpathExpression.*;
...
any(div().with(ul().with(li().atIndex(2)))).toXpath();

Will return the xpath expression

//div/ul/li[2]

Версии библиотеки

Версия
1.1