View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > XmlElemNew PreviousNext

XmlElemNew

Creates an XML document object element.

An XML document object element.

Extensibility functions, XML functions

XmlElemNew(xmlObj, childName)

cfxml, IsXmlDoc, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlSearch, XmlTransform

ColdFusion MX: Added this function.

Parameter

Description

xmlObj

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

childName

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

The following example creates and displays a ColdFusion document object. For more information on this example, see Using XML and WDDX in Developing ColdFusion MX Applications.

<cfset testVar = True>
<cfscript>
   MyDoc = XmlNew();
   MyDoc.xmlRoot = XmlElemNew(MyDoc,"MyRoot");
   if (testVar IS TRUE)
      MyDoc.MyRoot.XmlText = "The value of testVar is True.";
   else 
      MyDoc.MyRoot.XmlText = "The value of testVar is False.";
   for (i = 1; i LTE 4; i = i + 1)
      {
      MyDoc.MyRoot.XmlChildren[i] = XmlElemNew(MyDoc,"childNode");
      MyDoc.MyRoot.XmlChildren[i].XmlText = "This is Child node " & i &".";
      }
</cfscript>
<cfdump var=#MyDoc#>

Contents > CFML Reference > ColdFusion Functions > XmlElemNew PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


incubus said on Nov 2, 2003 at 11:47 AM :
watch out .. XMLELEMNEW works ony if you give XML Doc Object an argument ..
<cfset response = XMLNew()>
<!--- Here repsonse is of XML Doc type so it works --->
<cfset response.xmlRoot = XmlElemNew(response, "SyncML")>
<cfset response.SyncML.XmlChildren[1] = XmlElemNew(response, "SyncHdr")>
<cfset response_synchdr = response.SyncML.SyncHdr>
<!--- Here response_syncbody is of Element type so it doesn't work --->
<cfset tempo = XmlElemNew(response_syncbody,"Status")>
<!--- you get an Tempo undefined error --->
<cfset ArrayAppend(response_syncbody.xmlChildren , tempo)>

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/funca122.htm