newbie
newbie

Reputation: 24635

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?

Upvotes: 8

Views: 3689

Answers (3)

Lukas Eder
Lukas Eder

Reputation: 220797

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>");

Upvotes: 3

Eran Betzalel
Eran Betzalel

Reputation: 4193

You can use either E4X or XPath to query your XML file. I would recommend using the new E4X technology as it's more easy to use than XPath.

jQuery only offers standard hierarchical functions to parse XML files (see here) as it's not his purpose to do otherwise.

Upvotes: 1

user207421
user207421

Reputation: 310884

The query syntax for XML is called XPath.

Upvotes: 6

Related Questions