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. Advertising

  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. Advertising

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. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    817
    Kevin Spencer
    May 17, 2005
  2. shruds
    Replies:
    1
    Views:
    786
    John C. Bollinger
    Jan 27, 2006
  3. Rick
    Replies:
    1
    Views:
    2,185
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 19, 2007
  4. HANM
    Replies:
    2
    Views:
    710
    Joseph Kesselman
    Jan 29, 2008
  5. P
    Replies:
    7
    Views:
    136
    Tad McClellan
    Jan 12, 2007
Loading...

Share This Page