Code Monkey home page Code Monkey logo

Comments (7)

jackcviers avatar jackcviers commented on July 18, 2024

@adamdecaf is this needed on dispatch? jsoup provides css selectors and dom manipulation.

from reboot.

adamdecaf avatar adamdecaf commented on July 18, 2024

There are some more features that xpath has that I haven't seen in jsoup. Are they there?

http://en.wikipedia.org/wiki/XPath_2.0#Function_library

from reboot.

jackcviers avatar jackcviers commented on July 18, 2024
  1. XPath only works for valid documents, afaik. See this Stack Overflow Answer jsoup works on tagsoup (invalid docs).
  2. For selection, with the regular css3 selectors and psuedo-selectors available from jsoup, the functions listed in that table (except for the datetime transformations) are covered. Since selectors are strings, you could use joda or something to create the correct corresponding string selector.
  3. For manipulation, the attr('name', 'value'), text('value'), html('html'), prepend('html'), append('html'), and wrap('html') methods are easier to use than corresponding XPath transformations.
  4. For extraction, the attr('name'), text('name'), outerHtml(), and html() methods are easier to understand and use than the Xpath counterparts.
  5. For traversal, siblingElements(), firstElementSibling(), lastElementSibling(), nextElementSibling(), previousElementSibling(), parent(), children(), child(int index) are easier to understand than XPath queries that do the same thing.
  6. The traversal and selector methods are chainable and contextual.

IMHO selector('#someId').parent().lastElementSibling() is easier than //[id='someId']/../following-sibling[last()] or some other such nonsense.

Take it from a front-end dev that has to make interactive guis with the DOM -- selectors, attr, text, outerHtml, innerHtml, nextSibling, parent, children are way easier to use than xpath or xslt. Developers use jQuery and dom traversal to select and change things, not xpath. On top of all of that, if you use </> on an xml document, you get all the niceties of scala native xml handling. My 2 cents.

from reboot.

adamdecaf avatar adamdecaf commented on July 18, 2024

Oh yes, I agree that whenever developers can use DOM selection, traversal, etc.. that they should always do that. However, not every legacy application will be able to do that. I'll close this for any future reference.

from reboot.

jackcviers avatar jackcviers commented on July 18, 2024

Right, but using </> they get a NodeSeq, and that allows them to use xpath,
right? If they move their application to reboot, it is a small change for
their application that is less invasive than Promises, imho.

On Thu, Mar 28, 2013 at 8:41 AM, Adam Shannon [email protected]:

Oh yes, I agree that whenever developers can use DOM selection, traversal,
etc.. that they should always do that. However, not every legacy
application will be able to do that. I'll close this for any future
reference.


Reply to this email directly or view it on GitHubhttps://github.com//issues/47#issuecomment-15588753
.

from reboot.

adamdecaf avatar adamdecaf commented on July 18, 2024

It lets them do similar things as xpath (and jsoup). They'll still have to deal with promises though. Unless I'm missing what you're saying?

from reboot.

jackcviers avatar jackcviers commented on July 18, 2024

@adamdecaf I don't think so. What I was saying was basically that switching the handler verb is less of an invasive refactor as modifying the application to deal with Promises correctly.

from reboot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.