dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Greater Than sign "<" causing problems in myData.load()?!

  1. #1
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991

    Greater Than sign "<" causing problems in myData.load()?!

    Hi guys

    I've been using onLoad XML on my software and it's been working well until today, i noticed incomplete output.. and upon investigating i was shocked to find out (if true) that onLoad XML can't handle < or > signs????

    You see i just need to bring in a whole bunch of string in it's rawest form, backslashes and all, and let my software handle parsing and securing code and all that.. loadVariables is outdated and it can't handle html special characters the way i want it to, and it "&" signs just ends the string (as expected in the URL form).. so I always thought using load() does this perfectly leaving the string im bringing into flash preserved...

    "
    //setup data
    myData = new XML();
    myData.onLoad = function(success) {
    wait();

    myDataString = myData.toString();
    //prompt("string=" + myDataString);


    ..........

    but now i just found out that myDataString is cut off on the first "<" sign encountered!! i was horrified coz i've been using this software i did for a long time already and Gawd knows how many cut offs i've had


    Is there a quick way to correct this? or perhaps a better method of bringin in PURE STRING into flash? although everything works except for this so a fix or a noHTML switch or somethign would be much preffered..

    Please help. ...

  2. #2
    Administrator Steve R Jones's Avatar
    Join Date
    Nov 2011
    Location
    Dallas, TX
    Posts
    83
    mmmmm...not sure if it'll help, but the < is the "less than" sign

  3. #3
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    lolz. yeh that's the less than sign.. but i dont see why it's getting parsed liked html code <XXX> stuff..

    "hello <world>" output from my database
    when brought into flash w/ New String(); load() method, should be exactly as
    "hello <world>"

    but what i get is
    "hello "

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Have you tried unescape();?

    string1:String = unescape(Node1);

  5. #5
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    35
    Sounds like you need to CDATA wrap your string elements. Post up a decent chunk of your XML so people can evaluate your problem with a bit more useful data.

  6. #6
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    thnx fruitbeard but it didnt work

    @ROB.Shelley
    well it's basically just a simple XML load routine..


    my intention was to load PURE STRING DATA preserving all the symbols and even ALT Keys etc , but there's no other way to do load string data into flash but via LoadVars (variable value pairing w/c gets really really uggly when loading string data w/ different punctuations and ampersands kill the variable definitely)
    the only other way i know of is loading via XML method .. and just convert it to string.. this atleast preserves ALL characters no matter how weird it is w/o needing to mess w/ encode/decode stuffs..

    so my code is something like this

    //setup data
    myData = new XML();
    myData.onLoad = function(success) {
    myDataString = myData.toString();
    trace("Chorva =" + myDataString);
    }
    myData.load(link);
    text output is
    "Hello World <-- so mainstream"



    but anyway i kinda figured it out now..

    the reason i wasnt getting any issues w/ this "<" sign before even when loading in HTML DOCUMENTS filled w/ a bunch of <> symbols.. is because... flash kinda tries and transalte XML code when being loaded, and processes <> tags right away.. and if you have an open tag w/o properly closing it.. then it will abruptly end where that open tag was..

    eg:
    "Hello World <-- so mainstream" // open tag <



    So... in my php script i simply have str_replace that < to ( . but this messes up the rest of my other data w/c has HTML data in em


    is there really no other way to bring in pure preserved text into flash??

    regards

    TJ
    Last edited by Tea_J; 10-16-2012 at 09:48 AM.

  7. #7
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    35
    Yes, you CDATA wrap the text you want in XML which is why I wanted to see a fuller example of the text string you're trying to bring in. For example:

    HTML Code:
    <data>
    <string><![CDATA[Some text you <i>want</i> that has <b>HTML</b> formatting tags in that are preserved using the Character Data wrapper in XML]]><string>
    </data>
    Loading that XML in to Flash as XML and then getting the string value of the string node will give you the preserved text you need.

    Cheers,
    Rob

  8. #8
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    hi Rob!

    ok so i tried that.. by adding this line in my php before outputting it


    $output = "<data>
    <string><![CDATA[$output]]><string>
    </data>";


    and it works!! well sort off.. now the < > symbols are getting translated to html safe characters of some sort..

    eg.
    pure string = >Yanah<;
    when inside flash already = &gt;Yanah&lt;

    so basically my html codes will break this way..

    i can add a routine to convert them back to proper <> signs.. but is there another way w/ the CDATA thing or Flash switch of some sort that will reallly just bring in the string as it is exactly? no url encoding or anything like that??


    Regards

    TJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center