[jQuery] Re: Convert xml string to dom document

2007-05-17 Thread Mike Alsup
Thanks, Remy. Good to know. Mike @Mike - I actually had that same function for a project I was working on, and IE plain refused to convert it to a DOM that I could work with. In the end, I used a bit of substring parsing to get the contents of the body, and dumped it in a hidden DIV (thus c

[jQuery] Re: Convert xml string to dom document

2007-05-17 Thread Remy Sharp
@Mike - I actually had that same function for a project I was working on, and IE plain refused to convert it to a DOM that I could work with. In the end, I used a bit of substring parsing to get the contents of the body, and dumped it in a hidden DIV (thus creating the DOM I needed): xml = xml.s

[jQuery] Re: Convert xml string to dom document

2007-05-16 Thread Mike Alsup
Here's a fn for converting strings to docs: function stringToDoc(s) { var doc; if (window.ActiveXObject) { doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = 'false'; doc.loadXML(s); } else doc = (new DOMParser()).parseFromString(s, 'text/xml'); r

[jQuery] Re: Convert xml string to dom document

2007-05-16 Thread Ⓙⓐⓚⓔ
ps... this may not work in IE! On 5/16/07, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote: if the files is xhtml (or xml of some type) and it's being served as text/html, the browser won't give you a dom. UNLESS you override the mime-type! beforeSend : function(req){req.overrideMimeType('text/xml')}, dataTyp

[jQuery] Re: Convert xml string to dom document

2007-05-16 Thread Ⓙⓐⓚⓔ
if the files is xhtml (or xml of some type) and it's being served as text/html, the browser won't give you a dom. UNLESS you override the mime-type! beforeSend : function(req){req.overrideMimeType('text/xml')}, dataType: "xml", inside the $,ajax call. On 5/16/07, tcollogne <[EMAIL PROTECTED]>

[jQuery] Re: Convert xml string to dom document

2007-05-16 Thread Sam Collett
You could try using the dataType option in $.ajax: $.ajax({ type: "GET", url: "mypage.php", data: "id=1", dataType: "xml" success: function(msg){ // do something } }); The HTML should be valid XML as well (i.e. if you changed the extension to 'xml' you could open it in IE