Skip to content

Instantly share code, notes, and snippets.

@cfmitrah
Created May 9, 2014 19:50
Show Gist options
  • Save cfmitrah/1045bce91e1d795dfd2c to your computer and use it in GitHub Desktop.
Save cfmitrah/1045bce91e1d795dfd2c to your computer and use it in GitHub Desktop.
Parse Adobe ColdFusion Documentation's TOC.xml file
<cfscript>
myxmldoc = XmlParse("#expandpath('.')#/toc.xml");
if(listfirst(server.coldfusion.productversion) gte 10)
selectedElements = XmlSearch(myxmldoc, "//topic[ upper-case(@label) = '#ucase(url.q)#' ]");
else
selectedElements = XmlSearch(myxmldoc, "//topic[ contains(translate(@label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') ,'#lcase(url.q)#') ]/@href");
</cfscript>
<cfif arrayLen(selectedElements) neq 0>
<cflocation url="#selectedElements[1].XmlAttributes.href#" addtoken="false">
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment