Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Question document.implementation.createDocument in Chrome&Safari

    As I expected, Chrome (which I believe is based very much on the WebKit project engine, same as Safari) is not able to return correctly an XML document as object on using the document.implementation.createDocument() method.

    The only workaround I have found is to use an AJAX request based on the XMLHttpRequest object.

    My question is:

    Do you know other workaround to load XML documents as objects on Safari & Chrome as well as in the other browsers?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #2
    ubh
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Location
    Portland, Oregon U.S.A.
    Posts
    443
    Thanks
    108
    Thanked 15 Times in 14 Posts
    Hey kor,
    I am far far from being any kind of expert when it comes to Ajax and XML.
    I have only utilized xmlHTTPRequests a few times (good stuff btw imo).

    I dont know if this has any information that is relevant to this issue beings it looks like its kinda for IE (I think, reply's on the page talk about using it in other browser so who knows).
    Dean Edwards wrote up this little blog about XML data islands.

    Might this be of any interest?
    http://dean.edwards.name/weblog/2006/04/easy-xml/

  • Users who have thanked ubh for this post:

    Kor (10-09-2008)

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Something like this maybe?

    Code:
    var xmlObj = new DOMParser().parseFromString(xmlString, "text/xml");
    Code is from the off the top of my head, think I got it right.

    There is another way with createDocument, something like this

    Code:
    var xmlElem = document.createElement("xml");
    xmlElem.innerHTML = xmlString;
    
    var xmlObj = document.implementation.createDocument("temp", "", null);
    for(var i=0; i<xmlElem.childNodes.length; i+=1) {
      xmlObj.importNode(xmlElem.childNodes.item(i), true);
    }
    Again, wrote it here. Been awhile since I played with this.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • Users who have thanked A1ien51 for this post:

    Kor (10-09-2008)

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Thanks ubh and A1ien51 for the responses. Yes, A1ien51, those might be good alternative, as in fact Chrome & Safari create something with document.implementation.createDocument(), but I suspect they create strings, not objects.

    I will test to see if a parser could solve that.

    Thanks again!
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •