{"id":30123306,"url":"https://github.com/pchudzik/fluentxpath","last_synced_at":"2025-08-10T14:33:11.011Z","repository":{"id":57726932,"uuid":"163757520","full_name":"pchudzik/fluentxpath","owner":"pchudzik","description":"Fluently build xpath expressions in java","archived":false,"fork":false,"pushed_at":"2019-01-12T13:51:58.000Z","size":125,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-16T12:04:59.712Z","etag":null,"topics":["builder","xpath","xpath-expression","xpath-generator","xpath-query","xpath-selectors"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","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/pchudzik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-01T18:27:46.000Z","updated_at":"2023-11-29T10:24:37.000Z","dependencies_parsed_at":"2022-09-11T17:02:42.629Z","dependency_job_id":null,"html_url":"https://github.com/pchudzik/fluentxpath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pchudzik/fluentxpath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchudzik%2Ffluentxpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchudzik%2Ffluentxpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchudzik%2Ffluentxpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchudzik%2Ffluentxpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pchudzik","download_url":"https://codeload.github.com/pchudzik/fluentxpath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchudzik%2Ffluentxpath/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269736458,"owners_count":24467024,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["builder","xpath","xpath-expression","xpath-generator","xpath-query","xpath-selectors"],"created_at":"2025-08-10T14:31:50.303Z","updated_at":"2025-08-10T14:33:10.985Z","avatar_url":"https://github.com/pchudzik.png","language":"Groovy","readme":"# fluentXPath\n\n[![Build Status](https://travis-ci.org/pchudzik/fluentxpath.svg?branch=master)](https://travis-ci.org/pchudzik/fluentxpath)\n\n## Introduction \nAllows to fluently build xpath expressions in java. When string concatenation or using string\ntemplates is troubling you when creating xpath expressions.\n\nNote that does not offer anything but builder for xpaths. It doesn't check if your xpath is valid\nit's nothing but syntactic sugar so you don't have to concatenate strings.\n\nIf you are using groovy or kotlin or any other jvm language with string interpolation you should\nprobably use string interpolation instead of this library.\n\n## Contents\n\n* [Introduction](#introduction)\n* [Contents](#contents)\n* [Sample](#sample)\n  * [Basic](#basic)\n  * [Samples](#samples)\n  * [Dynamic xpaths](#dynamic-xpaths)\n  * [Missing functions](#missing-functions)\n* [Usage](#usage)\n  * [Releases](#releases)\n  * [Snapshots](#snapshots)\n* [Development](#development)\n* [Changelog](#changelog)\n  * [1.0.0 - 12.01.2019](#100---12012019)\n\n## Sample\n\n### Basic\n\n```\nString builderCommentsLink = xpathOf()\n    .anyElement(\"div\")\n    .has(\n            xpathFn().and(asList(\n                    xpathFn().eq(xpathAttribute(\"data-test-article-id\"), xpathValue(articleId)),\n                    xpathFn().contains(xpathFn().lowerCase(xpathAttribute(\"data-test-article-category\")), xpathValue(articleCategory)))))\n    .descendantElement(\"span\")\n    .has(\n            xpathFn().contains(\n                    xpathAttribute(\"class\"),\n                    xpathValue(\"links\")))\n    .descendantElement(\"a\").has(xpathFn().contains(xpathFn().lowerCase(xpathFn().text()), xpathValue(articleCommentsLinkText)))\n    .build();\n```\n\n### Samples\n\n* [src/main/java/com/pchudzik/fluentxpath/api/Demo.java](src/main/java/com/pchudzik/fluentxpath/api/Demo.java)\n* [src/test/groovy/com/pchudzik/fluentxpath/api/MSDNSamplesTest.groovy](src/test/groovy/com/pchudzik/fluentxpath/api/MSDNSamplesTest.groovy)\n* [src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderExpressionTest.groovy](src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderExpressionTest.groovy)\n* [src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderFunctionTest.groovy](src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderFunctionTest.groovy)\n* [src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderAxisTest.groovy](src/test/groovy/com/pchudzik/fluentxpath/api/XPathBuilderAxisTest.groovy)\n\n### Dynamic xpaths\n\nYou can dynamically build xpaths like with JPA's criteria builder adding conditions, loops, etc:\n```\nxpathOf()\n    .anyElement(\"div\")\n    .has(\n            xpathFn().and(asList(\n                    xpathFn().or(articleIdIn(newArticleIds)),\n                    xpathFn().contains(xpathFn().lowerCase(xpathAttribute(\"data-test-article-category\")), xpathValue(articleCategory)))))\n    .descendantElement(\"span\")\n    .has(\n            xpathFn().contains(\n                    xpathAttribute(\"class\"),\n                    xpathValue(\"links\")))\n    .descendantElement(\"a\").has(xpathFn().contains(xpathFn().lowerCase(xpathFn().text()), xpathValue(articleCommentsLinkText)))\n    .build();\n```\n\n### Missing functions\n\n1. Pull requests are welcome\n1. Implement it on your own:\n```\nprivate static class XPathCount implements XPathExpression {\n    private final XPathExpression expression;\n\n    private XPathCount(XPathExpression expression) {\n        this.expression = expression;\n    }\n\n    @Override\n    public String build() {\n        return \"count((\" +\n                expression.build() +\n                \"))\";\n    }\n}\n\nxpathFn().greaterThan(\n        new XPathCount(xpathOf().anyElement(\"a\").has(xpathFn().contains(xpathAttribute(\"class\"), xpathValue(\"links\")))),\n        xpathValue(4))\n    .build();\n```\n\n## Usage\n\n### Releases\n\nAdd maven dependency:\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.pchudzik\u003c/groupId\u003e\n  \u003cartifactId\u003efluentxpath\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIn gradle:\n\n```\ncompile \"com.pchudzik:fluentxpath:1.0.0\"\n```\n\nAdd static imports:\n\n```\nimport static com.pchudzik.fluentxpath.api.XPathBuilder.*\nimport static com.pchudzik.fluentxpath.api.XPathExpression.xpathValue\n``` \n\nStart building your xpaths.\n\n### Snapshots\n\nConfigure nexus snapshots repository:\n\n```\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003esonatype-snapshots\u003c/id\u003e\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nAdd dependency to fluentxpath\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.pchudzik\u003c/groupId\u003e\n  \u003cartifactId\u003efluentxpath\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.1-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIn gradle:\n\n```\ncompile \"com.pchudzik:fluentxpath:1.0.1-SNAPSHOT\"\n``` \n\n## Development\n\n### Application version\n\nApplication version is configured in [gradle.properties](gradle.properties) file and is managed\nmanually. Remove -SNAPSHOT when releasing version and bump to next -SNAPSHOT version after release.\n\n### Deployment\n\nSnapshot are automatically deployed with every build on master branch (on\n[travis-ci](https://travis-ci.org/pchudzik/fluentxpath)). See [.travis.yml](.travis.yml) file for\ndetails.\n\nReleases are deployed manually from local machine using following incantation:\n\n```./gradlew clean publish closeRepository -DnexusUsername=secret -DnexusPassword=secret_password```\n\nAfter release go to [https://oss.sonatype.org/#stagingRepositories](oss.sonatype.org) and release\nrepository.\n\n## Changelog\n\n### 1.0.0 - 12.01.2019\n\n* 1.0.0 - 12.01.2019 - First released version\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchudzik%2Ffluentxpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpchudzik%2Ffluentxpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchudzik%2Ffluentxpath/lists"}