<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seth Kinast's Blog &#187; application/xhtml+xml</title>
	<atom:link href="http://sethkinast.com/tag/applicationxhtmlxml/feed/" rel="self" type="application/rss+xml" />
	<link>http://sethkinast.com</link>
	<description>I like shiny things</description>
	<lastBuildDate>Thu, 28 Jul 2011 05:12:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>jQuery &amp; application/xhtml+xml</title>
		<link>http://sethkinast.com/2008/01/22/jquery-applicationxhtmlxml/</link>
		<comments>http://sethkinast.com/2008/01/22/jquery-applicationxhtmlxml/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 23:01:48 +0000</pubDate>
		<dc:creator>Seth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[application/xhtml+xml]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://sethkinast.com/2008/01/22/jquery-applicationxhtmlxml/</guid>
		<description><![CDATA[For reasons previously discussed, serving your site up as application/xhtml+xml is a good thing to do. Check that post for all the reasons why. So now, you&#8217;ve taken the plunge and swapped your content-types. Whoa! Why did everything on your site just break? The first reason, of course, is invalid HTML. If you&#8217;re getting the [...]]]></description>
			<content:encoded><![CDATA[<p>For <a href="/2005/03/01/applicationxhtmlxml/">reasons previously discussed</a>, serving your site up as <code>application/xhtml+xml</code> is a good thing to do. Check that post for all the reasons why.</p>
<p>So now, you&#8217;ve taken the plunge and swapped your content-types. Whoa! Why did everything on your site just break? The first reason, of course, is invalid HTML. If you&#8217;re getting the <a href="http://www.answers.com/Yellow%20Screen%20of%20Death">Yellow Screen of Death</a> in Firefox, just fix what it asks and you&#8217;ll be back on track. However, if your <em>JavaScript</em> suddenly bites it, chances are that you were using methods that are deprecated and no longer supported. You see, when traversing an XML DOM, everything must be viewed in terms of elements. You can&#8217;t munge or alter the raw code, because you might generate invalid markup. Instead, you must insert, delete, or change existing elements.</p>
<p>&#8220;But but!&#8221; you cry. &#8220;I used the latest version of jQuery, just like you taught me! And I didn&#8217;t use anything but jQuery methods!&#8221; Well that&#8217;s great, but even jQuery can only do so much. Some of its methods rely on the unsupported <code>innerHTML</code>. So here&#8217;s how you fix the issues. Hey, it could be worse; you could have been using <code>document.write</code>!</p>
<h3>html() &#038; html(val)</h3>
<p><a href="http://docs.jquery.com/Attributes/html">These methods rely on <code>innerHTML</code>.</a> Consider using <code>text()</code> instead to only replace the text inside elements. If you were using <code>html()</code> to copy an element&#8217;s contents, try <code>clone()</code>. Finally, if you used <code>html()</code> because you really wanted all the elements inside, use <code>children()</code>. The key is to think of an element&#8217;s contents as nodes along the DOM tree, rather than a bunch of tag soup. Is there an <code>&lt;img /&gt;</code> inside your element? Don&#8217;t try to copy the HTML somewhere else. Just think, &#8220;Hey, I have an image element there. I can query for its src value, which is the important part. Then, I can recreate that image anywhere I want.&#8221; Elements are always replaceable&#8211; you need only give them back their attributes.</p>
<h3>$(&#8220;html here&#8221;)</h3>
<p>This is a slightly lesser-used aspect of jQuery. It&#8217;s used to <a href="http://docs.jquery.com/Core/jQuery#html">inject raw HTML into the DOM</a>. See a problem? Yep, XHTML+XML doesn&#8217;t do raw HTML. Everything is elements! Fortunately, it&#8217;s easy to fix this in your code. Instead of <code>$("&lt;img src='muu.png' /&gt;")</code>, try using <code>$(document.createElement("img")).attr("src","muu.png");</code> Not too hard, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://sethkinast.com/2008/01/22/jquery-applicationxhtmlxml/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

