Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22396 > unrolled thread

Using XPath for HTML Documents in IE

Started byPatient Guy <pg@keepItOnTheUse.Net.invalid>
First post2013-12-25 12:23 +0000
Last post2013-12-25 12:52 -0200
Articles 5 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  Using XPath for HTML Documents in IE Patient Guy <pg@keepItOnTheUse.Net.invalid> - 2013-12-25 12:23 +0000
    Re: Using XPath for HTML Documents in IE Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2013-12-25 14:16 +0100
      Re: Using XPath for HTML Documents in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-25 22:53 +0100
    Re: Using XPath for HTML Documents in IE "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-25 15:11 +0100
    Re: Using XPath for HTML Documents in IE Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-25 12:52 -0200

#22396 — Using XPath for HTML Documents in IE

FromPatient Guy <pg@keepItOnTheUse.Net.invalid>
Date2013-12-25 12:23 +0000
SubjectUsing XPath for HTML Documents in IE
Message-ID<XnsA2A14B1D42F05UVAA@78.46.70.116>
Mozilla's Firefox and Google's Chrome provide support for XPath in HTML 
documents.  There may be other browsers that do as much.

But one of those http clients is not Microsoft's Internet Explorer, still 
used (and even preferred!!) by countless number of individuals.  

[Aside: with its latest versions of IE, it does seem that Microsoft is trying 
harder to help web developers with a debugging tool, and possibly conform to 
standards it has helped to develop and pretended to support in the past.  
Your view will certainly vary.]

IE purportedly supports XPath for XML documents (not tested by me), but not 
for valid HTML documents (tested by me using document.evaluate method).

Are there any solutions (Microsoft implementations? library code by others?) 
for using XPath in HTML within IE of which I am unaware?

Solutions considered by me and judged not workable:

1. Spending days writing my own bug-ridden hack as library code for XPath to 
make it work in IE

2. Re-writing the HTML documents into far less readable and quite verbose 
valid XHTML is out of the question and should be unnecessary at any rate.

[toc] | [next] | [standalone]


#22398

FromBjoern Hoehrmann <bjoern@hoehrmann.de>
Date2013-12-25 14:16 +0100
Message-ID<lhmlb9d7qhghqnh3fhr45ho471g2vauiij@hive.bjoern.hoehrmann.de>
In reply to#22396
* Patient Guy wrote in comp.lang.javascript:
>Are there any solutions (Microsoft implementations? library code by others?) 
>for using XPath in HTML within IE of which I am unaware?

There are a number of XPath implementations written in JavaScript that
can be used to support browsers without native support for this feature.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

[toc] | [prev] | [next] | [standalone]


#22403

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-12-25 22:53 +0100
Message-ID<1848058.DKVRpigTNj@PointedEars.de>
In reply to#22398
Bjoern Hoehrmann wrote:

> * Patient Guy wrote in comp.lang.javascript:
>> Are there any solutions (Microsoft implementations? library code by
>> others?) for using XPath in HTML within IE of which I am unaware?
> 
> There are a number of XPath implementations written in JavaScript that
> can be used to support browsers without native support for this feature.

Which do you recommend?

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#22399

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-12-25 15:11 +0100
Message-ID<XnsA2A19A875A9A4eejj99@194.109.133.133>
In reply to#22396
Patient Guy <pg@keepItOnTheUse.Net.invalid> wrote on 25 dec 2013 in 
comp.lang.javascript:

> Mozilla's Firefox and Google's Chrome provide support for XPath in HTML 
> documents.  There may be other browsers that do as much.

Expats having a different culture to natives of this NG, I suppose.

"XPath is used to navigate through elements and attributes in an XML 
document."

So what would you want it to do in ordinary HTML, or even HTML5,
where there is, or should be, no XML structure present?

Better write specific code on what you really want to achieve.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#22400

FromJoao Rodrigues <groups_jr-1@yahoo.com.br>
Date2013-12-25 12:52 -0200
Message-ID<l9erf6$1bs$1@speranza.aioe.org>
In reply to#22396
On 25/12/2013 10:23, Patient Guy wrote:
> IE purportedly supports XPath for XML documents (not tested by me), but not
> for valid HTML documents (tested by me using document.evaluate method).
>
> Are there any solutions (Microsoft implementations? library code by others?)
> for using XPath in HTML within IE of which I am unaware?
>
> Solutions considered by me and judged not workable:
>
> 1. Spending days writing my own bug-ridden hack as library code for XPath to
> make it work in IE

IE supports the ActiveX MSXML2.DOMDocument which you can use:
<http://www.nczonline.net/blog/2009/04/04/xpath-in-javascript-part-3/>

However I think there are some JavaScript libraries that will help to 
using the XPath syntax in a cross-browser fashion.

>
> 2. Re-writing the HTML documents into far less readable and quite verbose
> valid XHTML is out of the question and should be unnecessary at any rate.
>

If a page doesn't use the 'application/xhtml+xml' MIME type [RFC3236], 
it will be served with a MIME type of text/html no matter it starts with 
the XHTML doctype or uses the XML syntax. It is important to say that 
the web server must be able to serve XHTML pages when triggered by the 
corresponding MIME Type.

MSIE 9 was the first version to recognize 'application/xhtml+xml' MIME type:
<http://blogs.msdn.com/b/ie/archive/2010/11/01/xhtml-in-ie9.aspx>

Also it is important to mention that the W3C shut down the XHTML 2 
Working Group in October, 2009, increasing resources on HTML 5:
<http://www.w3.org/News/2009#entry-6601>

Therefore, solution #2 is correct: don't waste your time writing XHTML 
pages.
-- 
Joao Rodrigues

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web