function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Colin LoretzColin Loretz 

Salesforce + Flex Output XML

I have used apex.query to query Salesforce and then I use a function to generate an XML object.
Code:
[Bindable]
private var myDevNotes:XML = <notes></notes>;

private function loadDevNotes():void
{
//Apex Query code removed for brevity
for (var j:int=0;j<qr.records.length;j++)
{
var newNote:XML =
<note sfid= {qr.records[j].Id}>
<name>{qr.records[j].Name}</name>
<detail>{qr.records[j].QA_Detail__c}</detail>
<createdBy>{qr.records[j].CreatedById}</createdBy>
<lastModified>{qr.records[j].LastModifiedDate}</lastModified>
</note>;
myDevNotes = myDevNotes.appendChild(newNote);
}
} 

Does anyone know of a way to then output this xml (myDevNotes) to an XML file, such as "data/devNotes.xml" ?

Thanks,
Colin
Ron HessRon Hess
You will have to use Adobe AIR to access the local filesystem (to write a file), Flex is inside the browser or flash player, no ready access to filesystem.
The AIR SDK has functions for writing to filesystem.
jf317820jf317820
Code:
var myXML:String = someXMLhere;
var file:File = File.desktopDirectory;
file = file.resolvePath("xmlFile.xml");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(myXML);

*this code is specific to Adobe AIR
Colin LoretzColin Loretz
Jf & Ron,

Thank you for your help.