Reputation: 23
What best meets my requirements in creating and modifying XML?
Requirements:
checking whether a node exists through the entire path from the root
<root>
<a>
<b>
</b>
</a>
<root>
-> //root/a/b
creating XML nodes with easy access to them, like expressions in XPath.
What can be recommend?
Upvotes: 1
Views: 161
Reputation: 4779
Perhaps this is overkill for you but XmlBeans from Apache is pretty cool and JAXB with Binders (which is perhaps a bit more modern) are both great options for modelling strictly defined XML (those with XSD Schema, DTD) in a Java friendly manner as simple beans. With a little extra coding, both can use XPath to reference elements within the XML data.
Upvotes: 0
Reputation: 33749
If you can use Groovy, XmlSlurper
plays nicely with Java, e.g. reading and updating. Groovy has its own expression language GPath, which has similar purpose as the more well-known XPath
.
Curious for more? Visit Groovy XML processing.
Upvotes: 0
Reputation: 10395
You can use Java XPath API in javax.xml.xpath
package. This is a tutorial
And to create XML nodes using XPath check this out
Upvotes: 2