parsing the <link> element tag

D

Doug.Sheahan

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
 
B

Bart Van der Donck

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top