cfxml vs xmlnew() vs xmlnew(true)

2008-06-30 Thread rex
Hello everyone,

I have this code that should generate the same exact XML three ways, but 
I can't get the third way to work.

1. cfxml - this works exactly the way I want it.

cfxml variable=whatIwant
breakfast_menu
   food
   name quantity=50 quantity2=150Belgian Waffles/name
   descriptionOur famous Belgian Waffles/description
   /food
   morefood/
/breakfast_menu
/cfxml
cfdump var=#whatIwant#/

2. xmlNew() - this works like cfxml, but quantity and quantity2 
attributes come out as uppercase

cfset myXML = XmlNew()/
cfset myXML.xmlRoot = XmlElemNew(myXML, breakfast_menu)/
cfset myXML.breakfast_menu.xmlChildren[1] = XmlElemNew(myXML, food)/
cfset myXML.breakfast_menu.xmlChildren[2] = XmlElemNew(myXML, 
morefood)/
cfset myXML.breakfast_menu.food.xmlChildren[1] = xmlElemNew(myXML, 
name)/
cfset myXML.breakfast_menu.food.xmlChildren[2] = xmlElemNew(myXML, 
description)/
cfset myXML.breakfast_menu.food.name.xmlText = Belgian Waffles/
cfset myXML.breakfast_menu.food.name.xmlAttributes.quantity = 50 
/!--- this comes out as uppercase ---
cfset myXML.breakfast_menu.food.name.xmlAttributes.quantity2 = 150 
/!--- this comes out as uppercase ---
cfset myXML.breakfast_menu.food.description.xmlText = Our famous 
Belgian Waffles/
cfset myXML.breakfast_menu.xmlChildren[2] = xmlElemNew(myXML, 
morefood)/
cfdump var=#myXML#/

3. xmlNew(true) - I'm trying to get the quantity/quantity2 attributes to 
be case sensitive.  I cannot get this to work at all.  I cannot add the 
child node name under food

cfscript
   myXML = xmlNew(true);
   myXML.xmlRoot = xmlElemNew(myXML, breakfast_menu);
   myXML.xmlRoot[breakfast_menu][1] = xmlElemNew(myXML, food);
   myXML.xmlRoot[breakfast_menu][1] = xmlElemNew(myXML, morefood);
   myXML.[breakfast_menu][food][1] = xmlElemNew(myXML, name);
   //myXML.xmlRoot[1][1][1] = xmlElemNew(myXML, name); //does not work
   //myXML[breakfast_menu][food][1] = xmlElemNew(myXML, name); 
//this does not work
   //myXML.xmlRoot[breakfast_menu][food][1] = xmlElemNew(myXML, 
name); //this does not work
   //myXML.xmlRoot[1][1][1] = xmlElemNew(myXML, name); //this does not 
work
/cfscript
cfdump var=#myXML#/

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=XML_08.html 
says not to use dot notation when referencing case sensitive XML.  One 
of the examples in there, I cannot get to work:

MyDoc.[employee][name][1]


which would translate to my code as:

myXML.[breakfast_menu][food][1]

I get an error saying 'A CFML variable name cannot end with a . 
character.'

Thanks for the help!



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308346
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: cfxml vs xmlnew() vs xmlnew(true)

2008-06-30 Thread Dominic Watson
I think the docs are in error. It should be:

myXML[breakfast_menu][food][1]

HTH

Dominic

2008/6/30 rex [EMAIL PROTECTED]:

 Hello everyone,

 I have this code that should generate the same exact XML three ways, but
 I can't get the third way to work.

 1. cfxml - this works exactly the way I want it.

 cfxml variable=whatIwant
 breakfast_menu
   food
   name quantity=50 quantity2=150Belgian Waffles/name
   descriptionOur famous Belgian Waffles/description
   /food
   morefood/
 /breakfast_menu
 /cfxml
 cfdump var=#whatIwant#/

 2. xmlNew() - this works like cfxml, but quantity and quantity2
 attributes come out as uppercase

 cfset myXML = XmlNew()/
 cfset myXML.xmlRoot = XmlElemNew(myXML, breakfast_menu)/
 cfset myXML.breakfast_menu.xmlChildren[1] = XmlElemNew(myXML, food)/
 cfset myXML.breakfast_menu.xmlChildren[2] = XmlElemNew(myXML,
 morefood)/
 cfset myXML.breakfast_menu.food.xmlChildren[1] = xmlElemNew(myXML,
 name)/
 cfset myXML.breakfast_menu.food.xmlChildren[2] = xmlElemNew(myXML,
 description)/
 cfset myXML.breakfast_menu.food.name.xmlText = Belgian Waffles/
 cfset myXML.breakfast_menu.food.name.xmlAttributes.quantity = 50
 /!--- this comes out as uppercase ---
 cfset myXML.breakfast_menu.food.name.xmlAttributes.quantity2 = 150
 /!--- this comes out as uppercase ---
 cfset myXML.breakfast_menu.food.description.xmlText = Our famous
 Belgian Waffles/
 cfset myXML.breakfast_menu.xmlChildren[2] = xmlElemNew(myXML,
 morefood)/
 cfdump var=#myXML#/

 3. xmlNew(true) - I'm trying to get the quantity/quantity2 attributes to
 be case sensitive.  I cannot get this to work at all.  I cannot add the
 child node name under food

 cfscript
   myXML = xmlNew(true);
   myXML.xmlRoot = xmlElemNew(myXML, breakfast_menu);
   myXML.xmlRoot[breakfast_menu][1] = xmlElemNew(myXML, food);
   myXML.xmlRoot[breakfast_menu][1] = xmlElemNew(myXML, morefood);
   myXML.[breakfast_menu][food][1] = xmlElemNew(myXML, name);
   //myXML.xmlRoot[1][1][1] = xmlElemNew(myXML, name); //does not work
   //myXML[breakfast_menu][food][1] = xmlElemNew(myXML, name);
 //this does not work
   //myXML.xmlRoot[breakfast_menu][food][1] = xmlElemNew(myXML,
 name); //this does not work
   //myXML.xmlRoot[1][1][1] = xmlElemNew(myXML, name); //this does not
 work
 /cfscript
 cfdump var=#myXML#/


 http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=XML_08.html
 says not to use dot notation when referencing case sensitive XML.  One
 of the examples in there, I cannot get to work:

MyDoc.[employee][name][1]


 which would translate to my code as:

myXML.[breakfast_menu][food][1]

 I get an error saying 'A CFML variable name cannot end with a .
 character.'

 Thanks for the help!



 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308347
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: cfxml vs xmlnew() vs xmlnew(true) - (Solved)

2008-06-30 Thread rex
I should be referencing the root node in xmlRoot:

cfscript
  myXML = xmlNew(true);
  myXML.xmlRoot = xmlElemNew(myXML, breakfast_menu);
  myXML.xmlRoot[food] = xmlElemNew(myXML, food);
  myXML.xmlRoot[morefood] = xmlElemNew(myXML, morefood);
  myXML.xmlRoot[food][name] = xmlElemNew(myXML, name);
/cfscript
cfdump var=#myXML#/

Thanks!

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308353
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4