views:

47

answers:

1

Hi guys, I'm currently attempting to communicate with an API using Flex as the client. I'm using Flash Builders HTTPServices to do so, bit of a noob to all this. All works correctly if the accessed XML files elements are formatted correctly however if I add a hyphen to the element name I get flex warning me to the fact ie. The returned object contains an invalid name "created-on" that does not conform to the Actionscript identifier naming guidelines

This works:

<?xml version="1.0" encoding="UTF-8"?>
<projects type="array">
  <project>
    <createdon>2010-07-10</createdon>
    <name>Project 1</name>
  </project>
</projects>

This does not:

<?xml version="1.0" encoding="UTF-8"?>
<projects type="array">
  <project>
    <created-on>2010-07-10</created-on>
    <name>Project 1</name>
  </project>
</projects>

My question then is what can I do to make the returned xml actionscript friendly. Is there a standard or a best practice for this? I obviously don't have any control over the xml being passed.

Cheers

A: 

Set the resultFormat of HTTPService to e4x or xml. The default value is object and hence Flex tries to create ActionScript object for each elements in the xml tree.

<mx:HTTPService resultFormat="xml" other="attributes go here"/>
Amarghosh