<?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>nerdboy.co.uk &#187; xpath</title>
	<atom:link href="http://www.nerdboy.co.uk/tag/xpath/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdboy.co.uk</link>
	<description>nerdboy blog - web development stuff</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:31:18 +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>Case insensitive xpath queries</title>
		<link>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/</link>
		<comments>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 10:43:30 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=90</guid>
		<description><![CDATA[I had an xpath query to test whether a node already exists in an xml document Unfortunately users were testing for values with different capitalisations so the program was reporting that the nodes didn&#8217;t exist when actually they did. I could have change the data in the xml file so that all data was stored [...]]]></description>
			<content:encoded><![CDATA[<p>I had an xpath query to test whether a node already exists in an xml document</p>
<pre class="brush: vb; title: ; notranslate">Dim KeyphraseNode As XmlNode = xmlDoc.SelectSingleNode( _

String.Format(&quot;/websites/website[@url='{0}']/keyphrases/keyphrase[@value='{1}' and @type='{2}']&quot; , _

WebsiteUrl, keyphrase.ToLower, keyphraseType))</pre>
<p>Unfortunately users were testing for values with different capitalisations so the program was reporting that the nodes didn&#8217;t exist when actually they did.</p>
<p>I could have change the data in the xml file so that all data was stored as lowercase, but that would be nasty.</p>
<p>After a bit of digging round and consulting my trusty xpath book I found that there isn&#8217;t a nice and easy lowercase function built into xpath.  And the best approach is to use the translate function.  So the solution turned out to be</p>
<pre class="brush: vb; title: ; notranslate">Dim KeyphraseNode As XmlNode = xmlDoc.SelectSingleNode( _

String.Format(&quot;/websites/website[@url='{0}']/keyphrases/keyphrase[translate(@value,

'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='{1}' and @type='{2}']&quot;, _

WebsiteUrl, keyphrase.ToLower, keyphraseType))</pre>
<p>Hope that helps if anyone else needs to do a case insensitive xpath search.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

