« Tasty new Nokia Prism CollectionFlash Lite Digital Personal Assistant for Jonnie Walker »

16 comments

  1. § tbm said on :
    cast with escape?
  2. § Richard Leggett® Email said on :
    Afraid not. It's already XML/HTML encoded as it needs to be when reaching the server. It seems that this same code behaves differently in the Flash 9 IDE as it does when running from the Flex SDK strangely.
  3. § paddy said on :
    you can try:
    trace(xml.toXMLString());

    it still doesn't do the quotes though ;(

    as mentioned trace(escape(xml)); may be your best bet...
  4. § Richard Leggett® Email said on :
    Hi paddy, afraid not, I need it to be HTML encoded (escape will only URL encode).

    The only solution I can see right now is to double HTML encode it, so that would be an " for a quote mark. However I still think it's working differently between the compilers, and both are different to Flash 8's behaviour. Still looking into it.
  5. § Ryan Matsikas said on :
    var imgSrc:String = "http://www.google.co.uk/intl/en_uk/images/logo.gif";
    var imgTag:XML = ;

    var xml:XML = Here is some text, with an image { imgTag };
    trace( xml );

    var ur:URLRequest = new URLRequest('http://myserver.com');
    var uv:URLVariables = new URLVariables();
    uv.param = xml.toString();

    ur.data = uv;
    trace(ur.data)
    ---

    Seems to work for me..
  6. § Ryan Matsikas said on :
    That was chewed up and spit out by your comment system :\

    http://out.chewtinfoil.com/rlXML.txt
  7. § Richard Leggett said on :
    Hi Ryan,

    Thanks for your sample. Unfortunately I'm not using e4x directly within ActionScript as per your example, the XML is originally dynamically generated as a string (or loaded from elsewhere) and then converted to an XML data type. My posted example probably didn't reflect the situation fully.

    So the problem is with the conversion that occurs in the XML constructor/parsing. It doesn't want to preserve the quote entity and there are no flags to allow you to keep it.
  8. § Robert Penner said on :
    The E4X is producing valid XML. It's just choosing to encode nothing more than is necessary. If instead, you put the same string in an attribute, the quotes toXMLString() escapes the quote, as necessary. But in that case, it uses a literal greater-than because escaping it isn't necessary. Shouldn't an XML-RPC system be supporting it if it's valid XML data?

    I have a somewhat reverse problem. I cannot get toXMLString() to output CDATA in a CDATA block. It outputs the escaped equivalent. So I can't put ActionScript source code into a CDATA and have it be legible coming back out of the XML object. If anyone figures out how to do this, let me know.
  9. § Richard Leggett® Email said on :
    Hi Robert,

    This is correct... A fully functional XML-RPC server should support unescaped quote marks in text nodes. But I was thrown by the commentary on:

    http://www.w3schools.com/xml/xml_cdata.asp

    Which suggests it is a good practice to encode those entities. So all in all, I don't have a problem at present, I just wanted the data to be the same as the server generated content which does use ". The CDATA scenario on the other hand definitely looks to be an issue. Do you have a sample online?
  10. § Robert Penner said on :
    Re: CDATA, it turns out AS3 handles it fine. I'm encountering the issue in JSFL, which gained E4X in Flash CS3 when we upgraded to the latest SpiderMonkey. I assumed it would work the same as in AS3, since everything else seems to.

    Here's a simple test:


    var script:String = "trace(1 < 2 && 2 > 1)";
    var str:String = '';
    var xml:XML = new XML( str );
    trace( xml.toXMLString() );

    -- AS3 Output --
    1)]]>

    -- JSFL Output --
    trace(1 < 2 && 2 > 1)

    hope all the characters make it through ok.
  11. § Robert Penner said on :
    Ack, that got mangled from two different directions. The crucial part is that str is:

    &lt;script&gt;&lt;![CDATA[trace(1 &lt; 2 && 2 &gt; 1)]]&gt;&lt;/script&gt;
  12. § Robert Penner said on :
    Oh well, I tried. The point is that AS3 outputs CDATA as expected, while SpiderMonkey 1.6 (JSFL) escapes it. I wonder what happens in Firefox's current E4X.
  13. § Richard Leggett® Email said on :
    Apologies for the blog mangling up the code there. It's supposed to accept HTML (unless you re-edit the comment I found).

    Just for anyone else reading... I think that code might be:

    var script:String = "<script><![CDATA[trace(1 < 2 && 2 > 1)]]></script>";

    Thanks for bringing this up though Robert, hopefully someone finds this when wondering why the E4X is behaving differently in JSFL compared to in AS3.

    Just noticed you posted that code snippet at "13:37"... nice ;)
  14. § Jack Peelsen said on :
    Looks like Robert Penner is right!
    I was try his test - it's work
  15. § Fabio said on :
    Hi,
    A small xml is easy using URLVariables.
    But my problem is send a big xml.
    Using URLVariables the browser says "URL TOO LONG".
    Must be another way...
    In Adobe Flash forum no one answer this question.
    I think Macromedia gave more attention to developers...
  16. § Alexis said on :
    +1 for Robert Penner

Comments are closed for this post.

Contact. ©2009 by Richard Leggett. multiple blogs / web hosting.
Design & icons by N.Design Studio. Skin by Tender Feelings / EvoFactory.
Entries RSS Comments RSS Log in