parsing the <link> element tag

Discussion in 'Javascript' started by Doug.Sheahan@gmail.com, Jun 23, 2006.

  1. Guest

    I am attempting to parse and xml file using javascript but am running
    into a problem when parsing a <link></link> pair. For example, the
    link information in most RSS feeds is given as

    <link> http://www.something.com/someotherstuff </link>

    However, when I use item.getElementsByTagName("link"), I get an empty
    HTMLLinkObject back and if I print the innerHTML property of item, the
    <link> tag shows up but not the </link> tag. Does anyone know of a
    javascript solution to this?

    Thanks,
    -Doug
     
    , Jun 23, 2006
    #1
    1. Advertisements

  2. wrote:

    > I am attempting to parse and xml file using javascript but am running
    > into a problem when parsing a <link></link> pair. For example, the
    > link information in most RSS feeds is given as
    >
    > <link> http://www.something.com/someotherstuff </link>
    >
    > However, when I use item.getElementsByTagName("link"), I get an empty
    > HTMLLinkObject back and if I print the innerHTML property of item, the
    > <link> tag shows up but not the </link> tag. Does anyone know of a
    > javascript solution to this?


    <script type="text/javascript">
    if (window.ActiveXObject) {
    xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
    xmlDoc.async = false;
    xmlDoc.load('file.xml');
    doAlert();
    }

    else if (document.implementation
    && document.implementation.createDocument) {
    xmlDoc = document.implementation.createDocument('', '', null);
    xmlDoc.load('file.xml');
    xmlDoc.onload = doAlert;
    }

    else {
    alert('Browser canĀ“t support script!');
    }

    function doAlert() {
    alert(xmlDoc.getElementsByTagName('link')[0].firstChild.nodeValue);
    }
    </script>

    --
    Bart
     
    Bart Van der Donck, Jun 24, 2006
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jstack
    Replies:
    1
    Views:
    786
    Tor Iver Wilhelmsen
    Jul 4, 2003
  2. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,714
    Wendy S
    Jul 9, 2003
  3. shahbaz
    Replies:
    0
    Views:
    1,096
    shahbaz
    Oct 27, 2003
  4. RC
    Replies:
    2
    Views:
    646
    Malte
    May 10, 2005
  5. shruds
    Replies:
    1
    Views:
    1,273
    John C. Bollinger
    Jan 27, 2006
  6. Rick
    Replies:
    1
    Views:
    2,961
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 19, 2007
  7. HANM
    Replies:
    2
    Views:
    1,528
    Joseph Kesselman
    Jan 29, 2008
  8. P
    Replies:
    7
    Views:
    418
    Tad McClellan
    Jan 12, 2007
Loading...