With a little side of applesauce...

Tuesday, July 22, 2008

Coldfusion - print string representation of XML

Sometimes, you just don't want the graph representation of XML that is printed with cfdump...

The following prints a string representation of the first xmlElement from an OpenDocument Format file (content.xml):

<cfzip action="read" file="#path#" entrypath="content.xml" variable="xmlContent"> 

<cfset variables.content = xmlParse(variables.xmlContent)>

<!--- now, let's insert our information into the document (username, time/date, state, comments, title) --->
<cfset variables.text = xmlSearch(variables.content, "/office:document-content/office:body/office:text")>

<cfset x = #toString(variables.content.xmlRoot.XmlChildren[2].XmlChildren[1].XmlChildren[1])#>
<cfoutput>#HtmlEditFormat( x )#</cfoutput>


http://www.bennadel.com/blog/962-Getting-The-String-Representation-Of-One-ColdFusion-XML-Node.htm

No comments: