Skip navigation
lucasbuck2
Currently Being Moderated

Text changes when pulling from an xml file

Jul 27, 2012 7:49 PM

I have a quiz game in Flash that pulls questions from .xml files. The questions are in this format:

 

> <q>A book of maps</q>

> <a>Atlas</a>

 

I’ve noticed I can’t put quotes or apostrophes in it. If I do it doesn’t display them, it shows &quot; or &apos;

 

Someone suggested actually putting in &quot; instead, but that just came out the same way. Any ideas of why it would do that or a way around it? Thanks for any help.

 
Replies
  • kglad
    62,194 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 27, 2012 10:52 PM   in reply to lucasbuck2

    use the replace method (as3) or split().join() (as2).

     
    |
    Mark as:
  • kglad
    62,194 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 28, 2012 9:20 AM   in reply to lucasbuck2

    for the quote (only), you must escape it.  and that should be

     

    &quot;

     

    no

     

    &quot

     

     

     

    function str_replace(str){

      return str.split("&quot;").join("\"");

    }

     

     

    that can be placed anywhere as long as it executes before it's called (which it will be if it's attached to the same frame where you load the text).

     
    |
    Mark as:
  • kglad
    62,194 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 28, 2012 5:17 PM   in reply to lucasbuck2

    you're welcome.

     

    p.s. please mark helpful/correct responses, if there are any.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 2:58 AM   in reply to lucasbuck2

    If you want to include punctuation inside your questions or answers you should wrap them inside CDATA blocks. This instructs the XML parser not to touch the content inside the blocks.

     

    <q><![CDATA[Put the text in here]]></q>

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 15, 2012 3:03 AM   in reply to lucasbuck2

    Where does this output (Put the &quot;text&quot;in here) get displayed? In the Output window, in a formatted text field?

     

    What happens when you trace out the xml object that loaded the xml file? The code would be something like trace(myXMLObject.q), depending on the name of your xml object and the structure of the xml file.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points