You do not want to send an XML object, you just want to send the string. It is the server that needs to convert the string to an XML Object. Just send it the characters. You may have to encode the string since HTTP has no idea about CDATA. The browser and server will look at every character inside the CDATA and look for things to process .

Try making it shorter.

var encodedString:String = "encoded string";

var XMLString:String;                   
XMLString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
XMLString += "<file>";
XMLString += "<![CDATA[" + encoded string + "]]>";                    
XMLString += "</file>";
                        
trace ("XMLString = " + XMLString); // Trace 1

//Need an encode here to protect the "encoded data" from interpretation         
              
                        
var scriptPath:String = uploadUrl + "?xml=" +  XMLString + "&key=" + _key +
"&session=" + _sessionId; 


Paul Steven wrote:
I am trying to convert a string to xml but for some reason when I convert to
xml it only displays the "encoded string". See below the code snippet for
what is traced. Any idea what I am doing wrong?

Here is my test file

var encodedString:String = "encoded string";

var XMLString:String;                   
XMLString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
XMLString += "<file>";
XMLString += "<![CDATA[" + encoded string + "]]>";                    
XMLString += "</file>";
                        
trace ("XMLString = " + XMLString); // Trace 1
                        
var dataToSend:XML = new XML(XMLString);
                        
trace ("dataToSend = " + dataToSend); // Trace 2              
                        
var scriptPath:String = uploadUrl + "?xml=" +  dataToSend + "&key=" + _key +
"&session=" + _sessionId; 

-------------
Trace Results
-------------
1.
XMLString = <?xml version="1.0" encoding="UTF-8"?><file><![CDATA[encoded
string]]></file>
2.
encoded string



_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to