var rp:XML = <reportParameters/>;
var service:CrmService = new CrmService();
service.addgetAllCustomersEventListener(customerResult);
service.addEventListener(FaultEvent.FAULT,serviceFaultHandler);
var custreq:GetAllCustomers_request = new GetAllCustomers_request ;
rp.appendChild(<start>{startdt.text}</start>);
rp.appendChild(<end>{enddt.text}</end>);
custreq.reportParameters = rp.toXMLString();
service.getAllCustomers_request_var = custreq;
service.getAllCustomers_send();
As you can see, you dont even need quotes around the XML tags, you can do free-form mixing of the tags with the Actionscript code. The variables appear in the curly braces {}. The method called toXMLString() converts all this into a string that looks like this:
<reportParameters><start>1/12/2010</start><end>3/14/2010</end></reportParameters>
The really exciting part is that the XML object managed the containing <reportParameters> tags so I didnt have to worry about closing it properly.
I really like this because now I do not have to write a lot of tedious code with all the open and closing quotes around each literal string and concatenating them together. I hope someone finds this useful.
I hate writing code where I have to carefully manage all beginning and ending
No comments:
Post a Comment