Parse XML with ColdFusion
We’re now doing project with different language, VB6 and CFMX7. One part of our projects, we need to send our data each other without uploading database files. That’s why we need to consider about exporting and importing XML files. In CFMX7, reading XML isn’t kinda complicated. Here is coding…
<cffile action=”read” file=”c:\inetpub\wwwroot\myfile.xml” variable=”XMLFileText” charset=”UTF-8″>
<cfset MyXMLDoc = xmlParse(XMLFileText)>
<cfset MyXMLNodes = xmlSearch(MyXMLDoc,’/Values/Comment’)>
<cfloop from=”1″ to=”#arraylen(MyXMLNodes)#” index=”i”>
<cfset GetXMLNodes = xmlparse(MyXMLNodes[i])>
<cfset ID = GetXMLNodes.Comment.CommentID.xmlText>
<cfset type = GetXMLNodes.Comment.CommentType.xmlText>
<cfset message = GetXMLNodes.Comment.CommentMessage.xmlText>
</cfloop>



