Someone recently requested an example for using the Microsoft XML Parser with CF5. Here is a small example that pulls in an XML news feed from SlashDot, parses the result, and displays a simple table of the lastest stories.

[cfhttp method="get"
url="http://slashdot.org/slashdot.xml"
path="c: emp"
file="slashdot.xml"
timeout="30" >


[cfobject action="create"
type="com"
class="microsoft.xmldom"
name="objxmldom">


[cfset xmlinputfile = "c: empslashdot.xml">

[cfset objxmldom.load(xmlinputfile)>

[cfset colbooklist = objxmldom.getelementsbytagname("story")>

"1">








[cfloop collection="#colbooklist#" item="story">
[cfset slash_title = story.selectsinglenode("title")>
[cfset slash_time = story.selectsinglenode("time")>
[cfset slash_author = story.selectsinglenode("author")>
[cfset slash_department = story.selectsinglenode("department ")>
[cfset slash_topic = story.selectsinglenode("topic")>
[cfset slash_url = story.selectsinglenode("url")>
[cfoutput>







[/cfoutput>
[/cfloop>
title time author department topic


"#slash_url.text#">#slash_title.text#

#slash_time.text# #slash_author.text# #slash_department.text# #slash_topic.text#



[cfset xmlerr = objxmldom.parseerror>

[cfoutput>
[cfif xmlerr.errorcode neq 0>--
errorcode: #xmlerr.errorcode#
errorreason: #xmlerr.reason#
[/cfif>
[/cfoutput>


Additional Resources: