If you want get the value "bar" from following XML file;
<test>
<property key = "test1" value = "foo" />
<property key = "test2" value = "bar" />
</test>
use XmlFileParseService#parse()
with four arguments, that identify the value to be taken.
XmlFileParseService service = new XmlFileParseService(new FileReadAdapter(new File("src/test/resources/test.xml")));
// tag name, key attribute name, key attribute value, value attribute name
// get "bar" as the value
String value = service.parse("property", "key", "test2", "value").get();
If there is no value in XML file, return "" with io.vavr.Try.
This application is built with the environment bellow;
- OpenJDK 17
- IntelliJ IDEA 2023.1.2
Note that this module is needed the gradle.properties on the root directory.
The property file is used when the module is published to GitHub Package manager.
Here is an example of the gradle.properties bellow (name must be set as your name);
GITHUB_USERNAME = zoeque
GITHUB_TOKEN = [[TOKEN]]