xmlElemNew

Creates an XML document object element

xmlElemNew(xmlobj [, namespace], childname) → returns xml

Argument Reference

xmlobj xml
Required

The name of an XML object. An XML document or an element.

namespace string

URI of the namespace to which this element belongs.

childname string
Required

The name of the element to create. This element becomes a
child element of xmlObj in the tree.

Examples
Sample code invoking the xmlElemNew function

Here, we've created myXml with root and child nodes using xmlelemnew().

<cfset myXml = xmlNew()>
<cfset myXml.XmlRoot = xmlelemnew(myXml,"sampleXml")>
<cfset myXml.sampleXml.XmlText = "This is Root node text">
<cfloop from="1" to="3" index="i">
	<cfset myXml.sampleXml.XmlChildren[i] = xmlelemnew(myXml,"childNode#i#")>
	<cfset myXml.sampleXml.XmlChildren[i].XmlText = "This is Child node#i# text">
</cfloop>
<cfdump var="#myXml#">

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub