Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there jQuery like selectors for Java XML parsing?

When I want to find elements from XML in with jQuery, i can just use CSS selectors. Is there any similar selector system for XML parsing in Java?

like image 203
newbie Avatar asked Feb 17 '10 07:02

newbie


2 Answers

The query syntax for XML is called XPath.

like image 178
user207421 Avatar answered Nov 07 '22 06:11

user207421


I am currently creating a sort of "jQuery port to Java". It is called jOOX and will provide most of jQuery's DOM navigation and manipulation methods. In addition to a simple selector expression language, standard XPath and XML transformation is supported, based on the standard Java DOM API

https://github.com/jOOQ/jOOX

Some sample code:

// Find the order at index for and add an element "paid"
$(document).find("orders").children().eq(4)
           .append("<paid>true</paid>");

// Find those orders that are paid and flag them as "settled"
$(document).find("orders").children().find("paid")
           .after("<settled>true</settled>");
like image 21
Lukas Eder Avatar answered Nov 07 '22 04:11

Lukas Eder