Hello everyone,
I am finally trying XML and coldfusion.  I' am able to parse an xml file and
display it; however I am running into problems when I attempt to add an
element.

The XML file looks like this:

<department name="Shipping Department">
<section name="Links">
<item>
<text>UPS website</text>
<link>http://www.ups.com/</link>
<description>Official UPS web Address</description>
</item>
<item>
<text>FedEx</text>
<link>http://www.fedex.com/</link>
<description>Get Tracking information from
FedEx</description>
</item>
</section>
</department>

I am trying to add a new section with name "Forms".

The code looks as follow:

<cffile action="" FILE="#menu_file#" variable="menu_data">
<cfset menu=XMLParse(menu_data)>

<cfset xnDepartment = menu.XmlRoot >
<cfset sDepartmentName = xnDepartment.XmlAttributes["name"] >
<cfset  nNumSections = ArrayLen(xnDepartment.XmlChildren)>

<!--- create our nwe secton--->
<cfset xnSectiona =  XmlElemNew(xnDepartment, "section")>

<!--- specify any attribues.---->
<cfset xnSectiona.XmlAttributes["name"] = "Forms">

<!--- now attach it to the XML Document --->
<cfset ArrayAppend(xnDepartment.XmlChildren, xnSectiona)>

The last line, is the one giving me problems.  Can anyone help please.

Thanks

Percy

Versa Products Company Inc
22 Spring Valley Road
Paramus NJ 07652
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to