Basic Ajax question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ChrisW

    Basic Ajax question

    I'm fairly new to Ajax - I understand the principles of XML, can do
    the PHP side, but am getting a bit lost with the JavaScript.

    I've seen a couple of different ways of using JS to manipulate the
    XML: 1 way using the getElementsByTa gName method (as advocated by
    W3Schools - http://www.w3schools.com/Dom/dom_nodes_get.asp) and a
    seemingly different method (http://scriptasylum.com/tutorials/
    xml_javascript/xml_javascript. html) - is either way recommended more
    or less (or any other way I haven't found yet)?

    I also haven't found any kind of decent API - is there one about? For
    example, I want to be able to get the value of an attribute from one
    of my nodes - I tried

    xmlDoc.getEleme ntsByTagName("i nfo")
    [0].childNodes[0].getAttribute(" type");

    but it doesn't work (in either IE or Firefox), but I can't find any
    other way to do it. Cross-browser compatibility is also a big concern
    for me, so if anyone can point me in the direction of a decent
    tutorial, I'd be most grateful!

    Thanks,
    Chris
  • Peter Michaux

    #2
    Re: Basic Ajax question

    On Jul 20, 11:35 am, ChrisW <c.c.w...@gmail .comwrote:
    I'm fairly new to Ajax - I understand the principles of XML, can do
    the PHP side, but am getting a bit lost with the JavaScript.
    >
    I've seen a couple of different ways of using JS to manipulate the
    XML: 1 way using the getElementsByTa gName method (as advocated by
    W3Schools -http://www.w3schools.c om/Dom/dom_nodes_get.a sp) and a
    seemingly different method (http://scriptasylum.com/tutorials/
    xml_javascript/xml_javascript. html) - is either way recommended more
    or less (or any other way I haven't found yet)?
    >
    I also haven't found any kind of decent API - is there one about? For
    example, I want to be able to get the value of an attribute from one
    of my nodes - I tried
    >
    xmlDoc.getEleme ntsByTagName("i nfo")
    [0].childNodes[0].getAttribute(" type");
    >
    but it doesn't work (in either IE or Firefox), but I can't find any
    other way to do it. Cross-browser compatibility is also a big concern
    for me, so if anyone can point me in the direction of a decent
    tutorial, I'd be most grateful!
    Do you know about JSON? It is generally preferred over XML these days.
    It is easier to extract data from the JSON when it has been converted
    to a JavaScript object than it is to extract data out of an XML
    document.



    Peter

    Comment

    • ChrisW

      #3
      Re: Basic Ajax question

      On 21 Jul, 03:12, Peter Michaux <petermich...@g mail.comwrote:
      On Jul 20, 11:35 am, ChrisW <c.c.w...@gmail .comwrote:
      >
      >
      >
      I'm fairly new to Ajax - I understand the principles of XML, can do
      the PHP side, but am getting a bit lost with the JavaScript.
      >
      I've seen a couple of different ways of using JS to manipulate the
      XML: 1 way using the getElementsByTa gName method (as advocated by
      W3Schools -http://www.w3schools.c om/Dom/dom_nodes_get.a sp) and a
      seemingly different method (http://scriptasylum.com/tutorials/
      xml_javascript/xml_javascript. html) - is either way recommended more
      or less (or any other way I haven't found yet)?
      >
      I also haven't found any kind of decent API - is there one about? For
      example, I want to be able to get the value of an attribute from one
      of my nodes - I tried
      >
      xmlDoc.getEleme ntsByTagName("i nfo")
      [0].childNodes[0].getAttribute(" type");
      >
      but it doesn't work (in either IE or Firefox), but I can't find any
      other way to do it.  Cross-browser compatibility is also a big concern
      for me, so if anyone can point me in the direction of a decent
      tutorial, I'd be most grateful!
      >
      Do you know about JSON? It is generally preferred over XML these days.
      It is easier to extract data from the JSON when it has been converted
      to a JavaScript object than it is to extract data out of an XML
      document.
      >

      >
      Peter
      Thanks for the link, though I still have a few questions.

      Is XML becoming obsolete? A couple of modules I did at a large UK
      university a couple of years ago seemed to promote XML as the ultimate
      data-handling tool, and that the XML-based databases etc were the best
      thing ever to have been invented.

      There are still reasons why I'd like to understand the XML-based
      methods - a lot of the ways of storing data in the scientific field I
      work in uses XML (e.g. STMML, MathML, and also RSS)

      I'm still worried about the issue of cross-browser compatibility - are
      the JS methods for manipulating JSON data better suited for this than
      the methods I found for XML, which only work in IE?

      Thanks,
      Chris

      Comment

      • Peter Michaux

        #4
        Re: Basic Ajax question

        On Jul 21, 6:03 am, ChrisW <c.c.w...@gmail .comwrote:

        [snip]
        Is XML becoming obsolete?
        No. Not at all.

        Many folks are choosing to use JSON as their data transport format
        rather than choosing XML.

        A couple of modules I did at a large UK
        university a couple of years ago seemed to promote XML as the ultimate
        data-handling tool, and that the XML-based databases etc were the best
        thing ever to have been invented.
        Some interesting perspectives:




        There are still reasons why I'd like to understand the XML-based
        methods - a lot of the ways of storing data in the scientific field I
        work in uses XML (e.g. STMML, MathML, and also RSS)
        If the systems already use XML then it is probably best to go with the
        flow and use XML.

        I'm still worried about the issue of cross-browser compatibility - are
        the JS methods for manipulating JSON data better suited for this than
        the methods I found for XML, which only work in IE?
        Extracting data from a JSON text that has been converted to a
        JavaScript object is much easier than extracting data from an XML
        document.

        Peter

        Comment

        Working...