<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The joy of&#8230; JavaScript&#039;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 entertainment, sports and culture.</description>
	<lastBuildDate>Wed, 10 Mar 2010 12:53:38 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Terry</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-20049</link>
		<dc:creator>Terry</dc:creator>
		<pubDate>Fri, 14 Aug 2009 17:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-20049</guid>
		<description>Craig, you just saved my facebook connect site! 

In most browsers the fb:profile-pic tag is replaced in parseDom by an img tag with the class of fb_profile_pic_rendered. In Safari on Mac I&#039;m getting the image but the class=&quot;&quot;. That makes it impossible to reference the image using getElementsByClassName and determine the src of the user thumbnail.

I switched the code to 
&lt;code&gt;statusImageSrc=document.getElementById(&quot;statusDiv&quot;).getElementsByTagName(&quot;img&quot;)[0].src;&lt;/code&gt;
and it works every time.</description>
		<content:encoded><![CDATA[<p>Craig, you just saved my facebook connect site! </p>
<p>In most browsers the fb:profile-pic tag is replaced in parseDom by an img tag with the class of fb_profile_pic_rendered. In Safari on Mac I'm getting the image but the class=&quot;". That makes it impossible to reference the image using getElementsByClassName and determine the src of the user thumbnail.</p>
<p>I switched the code to<br />
<code>statusImageSrc=document.getElementById("statusDiv").getElementsByTagName("img")[0].src;</code><br />
and it works every time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-17375</link>
		<dc:creator>Kris</dc:creator>
		<pubDate>Wed, 17 Dec 2008 05:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-17375</guid>
		<description>Thanks Craig! That saved me a lot of time realizing my own silly mistake :S</description>
		<content:encoded><![CDATA[<p>Thanks Craig! That saved me a lot of time realizing my own silly mistake :S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16942</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 11 Sep 2008 21:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16942</guid>
		<description>Arh, got it,

Silly mistake, checking the nodeValue for null, obviously can&#039;t happen because it doesn&#039;t exist:

if(currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild == null)

Works, Rather than

if(currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild.nodeValue == null)

Thanks anyway, lol</description>
		<content:encoded><![CDATA[<p>Arh, got it,</p>
<p>Silly mistake, checking the nodeValue for null, obviously can't happen because it doesn't exist:</p>
<p>if(currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild == null)</p>
<p>Works, Rather than</p>
<p>if(currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild.nodeValue == null)</p>
<p>Thanks anyway, lol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16941</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 11 Sep 2008 21:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.drunkenfist.com/304/2007/06/07/the-joy-of-javascripts-getelementsbytagname/#comment-16941</guid>
		<description>Hi,

Regarding #7:

I&#039;m having an issue, i&#039;m storing values from an xml file in a javascript variable. Like:

&lt;code&gt;
currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild.nodeValue
&lt;/code&gt;

I&#039;m doing this using Ajax, my XML results are created on the fly from the database via a super class. Everything is working fine except where a field in my database contains a null value. FF error console says:

&lt;code&gt;
currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild is null
&lt;/code&gt;

I&#039;ve only just started getting into this Ajax thing, and use Javascript very rarely. I&#039;ve tried to handle the null value like so:

&lt;code&gt;
 if(currentResult.getElementsByTagName(&quot;town&quot;).item(0).firstChild.nodeValue == null)
{

    var town = &quot; &quot;;
			
} 
&lt;/code&gt;

But I still get the javascript error presumably on the conditional statement. It&#039;s hard to track the location as I have several PHP, and Javascript files included.

Any ideas on handling the Null value?

Cheers

Craig</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Regarding #7:</p>
<p>I'm having an issue, i'm storing values from an xml file in a javascript variable. Like:</p>
<p><code><br />
currentResult.getElementsByTagName("town").item(0).firstChild.nodeValue<br />
</code></p>
<p>I'm doing this using Ajax, my XML results are created on the fly from the database via a super class. Everything is working fine except where a field in my database contains a null value. FF error console says:</p>
<p><code><br />
currentResult.getElementsByTagName("town").item(0).firstChild is null<br />
</code></p>
<p>I've only just started getting into this Ajax thing, and use Javascript very rarely. I've tried to handle the null value like so:</p>
<p><code><br />
 if(currentResult.getElementsByTagName("town").item(0).firstChild.nodeValue == null)<br />
{</p>
<p>    var town = " ";</p>
<p>}<br />
</code></p>
<p>But I still get the javascript error presumably on the conditional statement. It's hard to track the location as I have several PHP, and Javascript files included.</p>
<p>Any ideas on handling the Null value?</p>
<p>Cheers</p>
<p>Craig</p>
]]></content:encoded>
	</item>
	<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&#039;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 &quot;array&quot; 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&#039;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=&quot;http://www.drunkenfist.com/304/2008/07/02/say-hello-to-javascripts-native-getelementsbyclassname/&quot; rel=&quot;nofollow&quot;&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 &quot;array&quot; 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 &quot;click&quot; for me in the past.

getElementsByTagName doesn&#039;t return an array. It&#039;s an &quot;array-like&quot; collection of HTML elements. If you do this:

alert(document.getElementsByTagName(&#039;p&#039;));

in Mozilla, you will be told &quot;[object HTMLCollection]&quot; since that is what it is. In more friendly-speak, it&#039;s known as a node list, but it is NOT an array. For example, the Array object&#039;s concat method won&#039;t work on it because it isn&#039;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 &quot;click&quot; for me in the past.</p>
<p>getElementsByTagName doesn't return an array. It's an &quot;array-like&quot; collection of HTML elements. If you do this:</p>
<p>alert(document.getElementsByTagName('p'));</p>
<p>in Mozilla, you will be told &quot;[object HTMLCollection]&quot; 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&#039;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(&quot;x&quot;)[0];

var objerrorcode = obj.getElementsByTagName(&quot;y&quot;)[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(&quot;x&quot;)[0];</p>
<p>var objerrorcode = obj.getElementsByTagName(&quot;y&quot;)[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(&quot;city&quot;) [0].id;

or 

xml_document.getElementsByTagName(&quot;city&quot;) [0].getAttribute(&quot;id&quot;);</description>
		<content:encoded><![CDATA[<p>could could try something like</p>
<p>xml_document.getElementsByTagName(&quot;city&quot;) [0].id;</p>
<p>or </p>
<p>xml_document.getElementsByTagName(&quot;city&quot;) [0].getAttribute(&quot;id&quot;);</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&#039;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 &#039;Test Contract&#039; with no problem, but how can i access the &#039;id&#039; 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>
</channel>
</rss>
