Force jQuery to accept XHTML string as XML?

Posted by MidnightLightning on Stack Overflow See other posts from Stack Overflow or by MidnightLightning
Published on 2011-01-13T19:45:57Z Indexed on 2011/01/13 19:53 UTC
Read the original article Hit count: 403

Filed under:
|

So, as part of a baseline OpenID implementation in Javascript, I'm fetching a remote page source through AJAX, and looking for the <link rel="openid.server" href="http://www.example.com" /> tag in the head. I'm using the jQuery javascript library for the AJAX request, but am unable to parse out the link tags.

Several other online sources talk about using the usual jQuery selectors to grab tags from XML/XHTML sources, but it seems jQuery can only get content from the body of an HTML document, not the head (which is where the link tags are; $(response).find('link') returns null). So, I'd either need to get jQuery to force this document into XML mode or otherwise get at the head tags.

Is there a way to force jQuery to parse the response of an AJAX query as XML, when it's in reality XHTML? Or do I need to fall back to regular expressions to get the link tags out?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ajax