SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to read XML Document

    How to read XML Document using Javascript.
    In IE, We can use ActiveXObject,
    But I required for Mozilla Browser...

    Please Help me on this.

    Thanks & Regards
    Adil.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Have a read of Bulletproof AJAX. He provides the code from the book and specifically, the fetchxml.js file from Chapter 4 which does exactly what you require.

    If you can't afford to buy it, borrow it from your local library.

    The code in the parseResponse() function is specific to his example, but it's useful too in that it helps demonstrate some easy ways of working with XML.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to read xml without using ActiveXObject
    Because Mozilla doesn't support ActiveXObject.

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the XMLHttpRequest object for modern browsers and an ActiveX object for IE 6.

    How to achieve this can be read here.

  5. #5
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Netscape imports an XML document through the method document.implementation.createDocument().
    http://www.quirksmode.org/dom/importxml.html

    I think this gives the info you need...i've only ever parsed XML through an ajax request ( sending headers back with the AJAX request) so i dont have any first hand experience.

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That script will fail in Safari 3 though, you are more safe (when it comes to do a cross-browser solution) using an Ajax request.

  7. #7
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really? It seems wierd to me to be making an ajax request if the xml doc is a local file anyway.

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by adilsyed View Post
    I want to read xml without using ActiveXObject
    Because Mozilla doesn't support ActiveXObject.
    This is why fetchxml.js is a very good solution, because it will only use the ActiveXObject if the browser can't handle the XMLHttpRequest that most other browsers use.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you guide me how to load XML documents without Ajax XMLHttp Request?

    i want to load it with something like:
    CreateDocument();...

    but cross browser.
    i tried to do it but i couldn't find any code that support all famous browsers like FireFox2, 3, IE 6, 7, opera9+, Safari

    Can any body help me to do it?


Bookmarks

Posting Permissions

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