yaronn / xpath.js

An xpath module for node, written in pure javascript
103 stars 100 forks source link

XPath selectors are case sensitive #1

Open mish15 opened 12 years ago

mish15 commented 12 years ago

Thanks for the project, i'm finding it useful, but one thing that stumped me for ages was the following XPath, which would not work but always had worked in PHP. I ended up seeing it was "NAME" instead of "name" in the html.

//*[@NAME='TrackingJobBody']

//*[@name='TrackingJobBody']

The two above are not the same.

yaronn commented 12 years ago

Hi Mish15

Sorry for the delay in answering.

The two xpath above seems equal. Did you meant to use NAME (cpas) instead of name (lower) in one of them?

If you also try here, it seems that case matters in xpath:

http://xpath.online-toolz.com/tools/xpath-editor.php

mish15 commented 12 years ago

Hey Yaron,

No problem, thanks for open sourcing the code, very appreciated. I actually used lower case, but the target page used all CAPS. I test parse these in chrome dev tools and our current PHP also parses without caring about case.

We need to parse a bunch of non-compliant malformed HTML, so i ended up using Node for the download and kick out to PHP for the parsing. Seems to work pretty well, but i would love to parse the XPaths in node if possible...

On 15 August 2012 21:39, Yaron Naveh notifications@github.com wrote:

Hi Mish15

Sorry for the delay in answering.

The two xpath above seems equal. Did you meant to use NAME (cpas) instead of name (lower) in one of them?

If you also try here, it seems that case matters in xpath:

http://xpath.online-toolz.com/tools/xpath-editor.php

— Reply to this email directly or view it on GitHubhttps://github.com/yaronn/xpath.js/issues/1#issuecomment-7753779.

Zearin commented 10 years ago

:+1: