<cffile action="read"
file="#xmlFile#"
variable="xml" />
<cfset xml = xmlParse(xml) />
<cfparam name="url.path" default="web-app" />
<cfset node = xmlSearch(xml, "/" & url.path) />
<cfset node = node[1] />
<cfif structKeyExists(url, "updateNode")>
<!--- lets update it --->
<cfset node.xmlText = form.xmlText />
<cffile action="write"
file="#xmlFile#"
output="#toString(xml)#" />
<cflocation url="?path=#url.path#" addtoken="false" />
</cfif>
<cfset children = node.xmlChildren />
<cfoutput>
<h1>ROOT
<cfset p = "" />
<cfloop list="#url.path#" index="segment" delimiters="/">
<cfset p = listAppend(p, segment, "/") />
/ <a href="?path=#p#">#segment#</a>
</cfloop>
</h1>
Text:
<form method="post" action="?updateNode&path=#url.path#">
<textarea name="xmlText" style="width:500px;height:200px;">#node.xmlText#</textarea>
<input type="submit" value="Update" />
</form>
<h1>Children</h1>
<ul>
<cfset indexMap = structNew() />
<cfloop from="1" to="#arrayLen(children)#" index="i">
<cfif NOT structKeyExists(indexMap, children[i].xmlName)>
<cfset indexMap[children[i].xmlName] = 0 />
</cfif>
<cfset indexMap[children[i].xmlName] += 1 />
<li><a href="?path=<cfif url.path NEQ ''>#url.path#/</cfif>#children[i].xmlName#[#indexMap[children[i].xmlName]#]">#children[i].xmlName#</a></li>
</cfloop>
</ul>
</cfoutput>
Code for this page:
<cffile action="read"
file="#getDirectoryFromPath(getCurrentTemplatePath())#app.cfm"
variable="body" />
<cfoutput><pre>#htmlEditFormat(body)#</pre></cfoutput>