<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>XMLELEMNEW</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">XMLELEMNEW</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Creates an XML document object element.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
An XML document object element.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
XML functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>XmlElemNew(xmlObj[, namespace], childName)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfxml, IsXmlElem, XmlChildPos, XmlFormat, XmlNew, XmlParse; Chapter&#160;35, "Using XML and WDDX" in ColdFusion MX Developer's Guide 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX&#160;7: Added the namespace parameter.
</p>

<p>
ColdFusion&#160;MX: Added this function.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
The function's return variable specifies the location of the new element in the document object. It must specify a valid location in the document object identified by the xmlObj parameter. The following statements show this use:
</p>
<pre>MyDoc.MyRoot.XmlChildren[2] = XmlElemNew(MyDoc,&quot;childNode&quot;);
ArrayAppend(MyDoc.MyRoot.XmlChildren, XmlElemNew(MyDoc,&quot;childNode&quot;));
</pre>
<p>
If you do not specify a namespace URI and use a namespace prefix in the childName parameter, ColdFusion checks to see if a namespace URI has already been specified for the prefix, and if so, uses that namespace.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span>
<p>
The following example creates and displays a ColdFusion document object:
</p>
<pre>&lt;cfscript&gt;
   MyDoc = XmlNew();
   MyDoc.xmlRoot = XmlElemNew(MyDoc,&quot;MyRoot&quot;);
   if (testVar IS TRUE)
      MyDoc.MyRoot.XmlText = &quot;The value of testVar is True.&quot;;
   else 
      MyDoc.MyRoot.XmlText = &quot;The value of testVar is False.&quot;;
   for (i = 1; i LTE 4; i = i + 1)
      {
      MyDoc.MyRoot.XmlChildren[i] = XmlElemNew(MyDoc,&quot;childNode&quot;);
      MyDoc.MyRoot.XmlChildren[i].XmlText = &quot;This is Child node &quot; &amp; i &amp;&quot;.&quot;;
      }
&lt;/cfscript&gt;
&lt;cfdump var=#MyDoc#&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="XMLOBJ">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">XMLOBJ</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Name of the XML document object in which you are creating the element</p>

  </td>
  </tr>
  </table>
</div>
<div id="NAMESPACE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">NAMESPACE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>(Optional) URI of the namespace to which this element belongs</p>

  </td>
  </tr>
  </table>
</div>
<div id="CHILDNAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CHILDNAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Name of the element to create</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
