Search code examples
javaandroidxmlcss-selectorschainability

Java library using css selectors to parse XML


Is there a jQuery like JAVA/Android library that uses CSS Selectors to parse the XML ?

Like :

String desc = myXML.find("bloc[type=pro]").get(0).attr("description");

Chainability is also what I'm looking for, in the same way of jQuery...

I hope this exists !


Solution

  • Since there are some bugs in other Libraries like Jsoup and Jericho is different from what I was expecting,

    I wrote a Class Extending the org.xml.sax.helpers.DefaultHandler which parse the XML. I then wrote two other Classes that look like Element and Elements from Jsoup containing two functions called find that handle the CSS3 Selector and attr that returns the attribute value.

    I'm now cleaning and commenting that code... I'll post the library later for who is interested in.

    xmlDoc.find("bloc[type=Pro]>act").attr("label");
    

    is now possible like in jQuery !


    Edit !

    Here is the link to access the code for who is interested : Google Code Project


    Moving to GitHub : https://github.com/ChristopheCVB/JavaXMLQuery