Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Xalan XPathAPI question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Joona I Palaste, post: 552897"] In our application's code, we need to use XPath expressions to fetch data from XML documents. I'm using the Apache Xalan XPath implementation to do this. The only thing I've not figured out is how to resolve variables. How can I set an XPath variable to some value from the Java code? For example: XML code: <document> <element name="foo">This is an element</element> <element name="bar">This is also an element</element> </document> Java code (simplified): Document document = getTheDocument(); //what to write here??? NodeIterator nl = XPathAPI.selectNodeIterator(document, "/document/element[name=$var]/text()"); This kind of code, as is, throws a RuntimeException about an unresolved variable "var". Of course it's unresolved, because I don't know how to resolve it! The part that says "//what to write here???" should set the variable "var" to "foo" so that the node iterator would find this node: This is an element How can I do this? Thanks for any help! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Xalan XPathAPI question
Top