<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: The joy of&#8230; JavaScript's getElementsByTagName()</title>
	<atom:link href="http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/</link>
	<description>Rob Larsen writes on web design and development, entertainment, sports and culture.</description>
	<pubDate>Sat, 06 Sep 2008 00:29:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: rob</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16868</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Mon, 25 Aug 2008 23:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16868</guid>
		<description>Hi Rafael. Thanks, that's a great point. I do make the point of calling the return a nodeList in the article. In the case of #4 I consciously chose to call it an "array" because I was thinking Vladimir (#3) was new to JS and would probably be confused by the difference between the two. For most beginners the difference doesn't matter.

I actually touch on the differences between nodeLists and arrays several times on the site, most recently in this post on &lt;a href="http://www.drunkenfist.com/304/2008/07/02/say-hello-to-javascripts-native-getelementsbyclassname/" rel="nofollow"&gt;getElementsByClassName&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi Rafael. Thanks, that's a great point. I do make the point of calling the return a nodeList in the article. In the case of #4 I consciously chose to call it an "array" because I was thinking Vladimir (#3) was new to JS and would probably be confused by the difference between the two. For most beginners the difference doesn't matter.</p>
<p>I actually touch on the differences between nodeLists and arrays several times on the site, most recently in this post on <a href="http://www.drunkenfist.com/304/2008/07/02/say-hello-to-javascripts-native-getelementsbyclassname/" rel="nofollow">getElementsByClassName</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16867</link>
		<dc:creator>Rafael</dc:creator>
		<pubDate>Mon, 25 Aug 2008 23:31:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16867</guid>
		<description>Regarding your post #4, I have a small nit-pick which might help someone, as it did make something "click" for me in the past.

getElementsByTagName doesn't return an array. It's an "array-like" collection of HTML elements. If you do this:

alert(document.getElementsByTagName('p'));

in Mozilla, you will be told "[object HTMLCollection]" since that is what it is. In more friendly-speak, it's known as a node list, but it is NOT an array. For example, the Array object's concat method won't work on it because it isn't an array. However, you can loop through it and it has a length property, which is why it is often confused with an array.</description>
		<content:encoded><![CDATA[<p>Regarding your post #4, I have a small nit-pick which might help someone, as it did make something "click" for me in the past.</p>
<p>getElementsByTagName doesn't return an array. It's an "array-like" collection of HTML elements. If you do this:</p>
<p>alert(document.getElementsByTagName('p'));</p>
<p>in Mozilla, you will be told "[object HTMLCollection]" since that is what it is. In more friendly-speak, it's known as a node list, but it is NOT an array. For example, the Array object's concat method won't work on it because it isn't an array. However, you can loop through it and it has a length property, which is why it is often confused with an array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rob</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16400</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Tue, 29 Apr 2008 11:59:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16400</guid>
		<description>Hi Rama, I'm not quite following. Do you have some sample XML I could take a look at?</description>
		<content:encoded><![CDATA[<p>Hi Rama, I'm not quite following. Do you have some sample XML I could take a look at?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rama</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16316</link>
		<dc:creator>Rama</dc:creator>
		<pubDate>Sat, 26 Apr 2008 08:20:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16316</guid>
		<description>Hi, 

   Do you have any idea about handling null values which are passed to getElementsByTagName(). 

For example 

var obj = xmlDoc.getElementsByTagName("x")[0];

var objerrorcode = obj.getElementsByTagName("y")[0];

where in xml , x is the parent of y. and y has some childNodes. if the complete tag ( somestuff ) itself is not passed , how can you handle this when y has some childNodes which have to be accessed ?</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>   Do you have any idea about handling null values which are passed to getElementsByTagName(). </p>
<p>For example </p>
<p>var obj = xmlDoc.getElementsByTagName("x")[0];</p>
<p>var objerrorcode = obj.getElementsByTagName("y")[0];</p>
<p>where in xml , x is the parent of y. and y has some childNodes. if the complete tag ( somestuff ) itself is not passed , how can you handle this when y has some childNodes which have to be accessed ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rob</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-15329</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Fri, 14 Dec 2007 18:18:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-15329</guid>
		<description>could could try something like

xml_document.getElementsByTagName("city") [0].id;

or 

xml_document.getElementsByTagName("city") [0].getAttribute("id");</description>
		<content:encoded><![CDATA[<p>could could try something like</p>
<p>xml_document.getElementsByTagName("city") [0].id;</p>
<p>or </p>
<p>xml_document.getElementsByTagName("city") [0].getAttribute("id");</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orlando</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-15328</link>
		<dc:creator>orlando</dc:creator>
		<pubDate>Fri, 14 Dec 2007 17:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-15328</guid>
		<description>i started to use getElementsByTagName by i can't figure it out how to access a property of the tag, for example , i have the following xml response:
Test Contract

i put the id property to identify the contract,
when i handle the response i get the inner text 'Test Contract' with no problem, but how can i access the 'id' property?

thanks,
orlando</description>
		<content:encoded><![CDATA[<p>i started to use getElementsByTagName by i can't figure it out how to access a property of the tag, for example , i have the following xml response:<br />
Test Contract</p>
<p>i put the id property to identify the contract,<br />
when i handle the response i get the inner text 'Test Contract' with no problem, but how can i access the 'id' property?</p>
<p>thanks,<br />
orlando</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rob</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14467</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Wed, 15 Aug 2007 00:35:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14467</guid>
		<description>this method returns an &lt;a href="http://en.wikipedia.org/wiki/Array" rel="nofollow"&gt;array&lt;/a&gt;, so, yes, [0] is an &lt;a href="http://en.wikipedia.org/wiki/Index_%28information_technology%29" rel="nofollow"&gt;index&lt;/a&gt;. it refers to the first member of the collection (since the count starts at 0). As for how to get it, if you've got a valid tag reference passed as an argument, then you've "got it." 

At that point you've got a reference to the object and can do whatever you want with it.</description>
		<content:encoded><![CDATA[<p>this method returns an <a href="http://en.wikipedia.org/wiki/Array" rel="nofollow">array</a>, so, yes, [0] is an <a href="http://en.wikipedia.org/wiki/Index_%28information_technology%29" rel="nofollow">index</a>. it refers to the first member of the collection (since the count starts at 0). As for how to get it, if you've got a valid tag reference passed as an argument, then you've "got it." </p>
<p>At that point you've got a reference to the object and can do whatever you want with it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vladimir Orlovsky</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14466</link>
		<dc:creator>Vladimir Orlovsky</dc:creator>
		<pubDate>Tue, 14 Aug 2007 23:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14466</guid>
		<description>document.getElementsByTagName("city") [0]


Need help!
No body explain how to handle element: "[0]"
in javascript.
What it is? 'index' of some kind.
How do I get it and pass it ?
Thanks.
Vladimir</description>
		<content:encoded><![CDATA[<p>document.getElementsByTagName("city") [0]</p>
<p>Need help!<br />
No body explain how to handle element: "[0]"<br />
in javascript.<br />
What it is? 'index' of some kind.<br />
How do I get it and pass it ?<br />
Thanks.<br />
Vladimir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14332</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sat, 21 Jul 2007 05:22:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14332</guid>
		<description>I'm a beginner playing around with Javascript and I'd like to ask you a question.

I realize the power of document.getElementsByTagName, which is how I found your page, and I'm trying to use it for a simple page I'm trying to create.

I have three menu options at the top of this page, which I am successfully using CSS to achieve a mouse rollover effect for each selection.

When a user clicks on one of these options, I want to store the &#60;a&#62; tag name into a variable using Javascript.

Here's my feeble attempt:

		&lt;a href="#Demog" rel="nofollow"&gt;Demographics&lt;/a&gt;
		&lt;a href="#Trafc" rel="nofollow"&gt;Website Traffic&lt;/a&gt;
		&lt;a href="#Rates" rel="nofollow"&gt;Rates &#38; Availability&lt;/a&gt;
	

And, here's my feeble attempt at creating a Javascript function--GetTg() to store the a tag reference to a variable name using  document.getElementsByTagName.


	function GetTg() {
	var TgVar = document.getElementsByTagName('a');
	}


Once I can store the anchor tag to a variable, I want to use it in a switch/case statement to display HTML based on the selection.

Any help is appreciated...</description>
		<content:encoded><![CDATA[<p>I'm a beginner playing around with Javascript and I'd like to ask you a question.</p>
<p>I realize the power of document.getElementsByTagName, which is how I found your page, and I'm trying to use it for a simple page I'm trying to create.</p>
<p>I have three menu options at the top of this page, which I am successfully using CSS to achieve a mouse rollover effect for each selection.</p>
<p>When a user clicks on one of these options, I want to store the &lt;a&gt; tag name into a variable using Javascript.</p>
<p>Here's my feeble attempt:</p>
<p>		<a href="#Demog" rel="nofollow">Demographics</a><br />
		<a href="#Trafc" rel="nofollow">Website Traffic</a><br />
		<a href="#Rates" rel="nofollow">Rates &amp; Availability</a></p>
<p>And, here's my feeble attempt at creating a Javascript function&#8211;GetTg() to store the a tag reference to a variable name using  document.getElementsByTagName.</p>
<p>	function GetTg() {<br />
	var TgVar = document.getElementsByTagName('a');<br />
	}</p>
<p>Once I can store the anchor tag to a variable, I want to use it in a switch/case statement to display HTML based on the selection.</p>
<p>Any help is appreciated&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Tulloch</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14007</link>
		<dc:creator>Bob Tulloch</dc:creator>
		<pubDate>Fri, 08 Jun 2007 06:11:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-14007</guid>
		<description>Neat informative article. I will definitely be borrowing these techniques ~ I really liked the combination of ById and ByTag.
PS
Please have a look at my site (www.EuropeanHospitalRegister.com) - any suggestions are gratefully received.</description>
		<content:encoded><![CDATA[<p>Neat informative article. I will definitely be borrowing these techniques ~ I really liked the combination of ById and ByTag.<br />
PS<br />
Please have a look at my site (www.EuropeanHospitalRegister.com) - any suggestions are gratefully received.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
