Creates an XML document object element

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

Argument Reference

xmlobj xml

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

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

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">
<cfdump var="#myXml#">

Fork me on GitHub