Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save igor-suhorukov/2caaad972728d6bc80e286654e2cfde7 to your computer and use it in GitHub Desktop.
Save igor-suhorukov/2caaad972728d6bc80e286654e2cfde7 to your computer and use it in GitHub Desktop.
reuse existing DOM model
Document document = DocumentBuilderFactory.newInstance().newInstance().newDocumentBuilder().parse(new File("pom.xml"));
try(QueryProcessor proc = new QueryProcessor("declare variable $mydoc external; $mydoc//node()[text()='Igor Sukhorukov']", context)) {
proc.bind("mydoc", document);
// Execute the query
Value result = proc.value();
// Print result as string.
System.out.println(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment