A possibly simpler way would be to build a structure then use the StructToXML 
udf from cflib.org (http://www.cflib.org/udf.cfm?ID=573) to convert the 
structure to properly formatted XML. Much less work involved

regards,
larry

>Hi everyone. Happy new (almost) year.
>
>I'm curious what you experts think is the best way to create XML. 
>Just taking dummy XML and populating it?
>
><cfset myxml ='<CustomerRequest>
><BillAddress>
><Addr1>#Address1#</Addr1>
><City>#City#</City>
><State>#State#</State>
><PostalCode>#Zip#</PostalCode>
></BillAddress>
></CustomerRequest>'>
>
><cfset myxml = xmlParse(myxml)>
>
>Or using CF functions?
>
><cfset myxml = xmlNew()>
><cfset myxml.xmlRoot = xmlElemNew(myxml, 'CustomerRequest')>
><cfset myxml.CustomerRequest.xmlChidren[1] = xmlElemNew(myxml, 'BillAddress')>
><cfset myxml.CustomerRequest.BillAddress.xmlChidren[1] = 
>xmlElemNew(myxml, 'Addr1')>
><cfset myxml.CustomerRequest.BillAddress.xmlChidren[2] = 
>xmlElemNew(myxml, 'City')>
><cfset myxml.CustomerRequest.BillAddress.xmlChidren[3] = 
>xmlElemNew(myxml, 'State')>
><cfset myxml.CustomerRequest.BillAddress.xmlChidren[4] = 
>xmlElemNew(myxml, 'PostalCode')>
><cfset myxml.CustomerRequest.BillAddress.Addr1.xmlText = Address1>
><cfset myxml.CustomerRequest.BillAddress.City.xmlText = City>
><cfset myxml.CustomerRequest.BillAddress.State.xmlText = State>
><cfset myxml.CustomerRequest.BillAddress.PostalCode.xmlText = Zip>
>
>It seems like the first way would take less time, less overhead and 
>be less confusing. But somehow it seems like the second way is the 
>"right" way.
>
>Opinions?
>-- 
>
>Bud Schneehagen - Tropical Web Creations, Inc.
>
>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
>Web Based Solutions / eCommerce Development & Hosting
>http://www.twcreations.com/ - http://www.cf-ezcart.com/
>Toll Free: 877.207.6397 - Local & Int'l Phone/Fax: 386.789.0968

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229580
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to