<?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>Barryvan &#187; internet explorer</title>
	<atom:link href="http://www.barryvan.com.au/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barryvan.com.au</link>
	<description>Music, Programming, Design</description>
	<lastBuildDate>Sun, 08 Jan 2012 08:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Internet Explorer DOMDocument &amp; XPath</title>
		<link>http://www.barryvan.com.au/2009/04/internet-explorer-domdocument-xpath/</link>
		<comments>http://www.barryvan.com.au/2009/04/internet-explorer-domdocument-xpath/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 04:10:38 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=144</guid>
		<description><![CDATA[I discovered a couple of interesting things about Internet Explorer&#8217;s MSXML2.DOMDocument object. It turns out that there are essentially two &#8220;production-quality&#8221; versions of it available: 3.0 and 6.0. Version 6.0 is much the better version, but it&#8217;s quite new, and not available on all systems. This means that in IE7 and IE8, instantiating a new [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered a couple of interesting things about Internet Explorer&#8217;s MSXML2.DOMDocument object. It turns out that there are essentially two &#8220;production-quality&#8221; versions of it available: 3.0 and 6.0. Version 6.0 is much the better version, but it&#8217;s quite new, and not available on all systems. This means that in IE7 and IE8, instantiating a new MSXML2.DOMDocument object gives you version 3.0.</p>
<p>Now most of the time, this isn&#8217;t a problem. Today, though, I was constructing an XPath expression that used the substring() function; something like this:</p>
<pre class="brush: xml">//Element[substring(Child, 1, 3)=&#039;abc&#039;]</pre>
<p>This will pull all Elements with a Child element whose value&#8217;s first three characters are &#8220;abc&#8221;. Not particularly complex. It turns out, though, that version 3.0 or the DOMDocument doesn&#8217;t actually use XPath as its default language: it uses a bastardised version of XPath called &#8220;XSLPatterns&#8221;, which just so happens to not support the substring() function at all.</p>
<p>So how do we deal with this situation? One way is to always instantiate version 6.0 of the DOMDocument:</p>
<pre class="brush: javascript">xd = new ActiveXObject(&#039;msxml2.DOMDocument.6.0&#039;)</pre>
<p>The problem with this approach is that, like I mentioned earlier, you can&#8217;t always be guaranteed that your users will have version 6.0 installed (even though it&#8217;s a free download). The safer way to deal with this problem is to switch the expression language to XPath in your 3.0 object:</p>
<pre class="brush: javascript">xd = new ActiveXObject(&#039;msxml2.DOMDocument&#039;);
xd.setProperty(&quot;SelectionLanguage&quot;, &quot;XPath&quot;);</pre>
<p>The advantage of this approach is that you&#8217;re not specifying a version, so when MS eventually changes the default to 7.0 (or whatever), your code will work without a problem.</p>
<p>For more information on this, check out  <a title="Microsoft XML Team's WebLog: Using the right version of MSXML in Internet Explorer" href="http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx">this blog post</a> from Microsoft&#8217;s XML team, which goes into a little bit more detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2009/04/internet-explorer-domdocument-xpath/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

