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> <description>Official UPS web Address</description>
</item>
<item>
<text>FedEx</text>
<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="read" 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.
Thanks
Percy
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> <description>Official UPS web Address</description>
</item>
<item>
<text>FedEx</text>
<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="read" 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.
Thanks
Percy