3

In .NET there is a lovely library that allows me to easily parse an external html page using xpath queries (HTML Agility Project) - the problem is I have to do that client-side, so only javascript. Is there any way to do that?

3
  • You're probably better off just using jQuery's CSS-style syntax. Commented Jul 20, 2012 at 13:42
  • Well anyone but IE provides XPath over HTML with the DOM Level 3 XPath API w3.org/TR/DOM-Level-3-XPath. But within the client "parse an external html page" is restricted by the same origin policy so getting a DOM representation you can apply the evaluate method to could be the real problem if the page is not coming from the same origin as the document with the script. Commented Jul 20, 2012 at 13:45
  • Well then I assume that what I want to do is not actually possible. Thanks anyway everyone Commented Jul 20, 2012 at 13:51

2 Answers 2

2

jQuery also supports xPath selector as well CSS, you can get more information from the link below.

http://docs.jquery.com/DOM/Traversing/Selectors

Sign up to request clarification or add additional context in comments.

Comments

1

You can try it https://github.com/andrejpavlovic/xpathjs

Actually there are a lot of it and there is an window.evaluate method by default.

But the reason why mostly all frameworks using selectors like jQuery/Mootols/Dojo (Sizzle) is that in all modern modern browsers it`s supports almostly native and gets fall back if it doesn't. So in most ways it's faster.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.