Skip navigation
Currently Being Moderated

Double Quotes Written as \" in Text File

Feb 24, 2011 1:29 AM

Hi All,

 

I've written some code that takes user input and adds it to some other static text which is then sent to php to be written to a text file. The file is just plain text but has the .xml extension so it can be used as a source of data. Because of the XML content the text has to contain quotes so I am looking for ways to escape the double quote characters with \" or using the alternative method of using a mixture of double and single quotes to differentiate content I want in the text file and the quotes that define the boundary of the text string. The code is working but the resultant XML looks wrong, with double quotes being written as \" even though I used the double/single quote method, so I'm a bit baffled why this is happening. Here's my code:

 

//php filewriter

var outLV = new LoadVars();

var inLV = new LoadVars();

var phpmess = undefined;

//all text strings defined with single quotes so double quotes are included

txt1 = '<?xml version="1.0" encoding="UTF-8"?><holder><pagestatus holdstatus="';

txt2 = '" filelink = "';

txt3= '" /></holder>'

trace(txt1+statTxt.text+txt2+swfTxt.text+txt3);

//

function sendData() {

//clears field

infoTxt.text = "";

//sets up variables to send to php

outLV.flashxml = txt1+statTxt.text+txt2+swfTxt.text+txt3;

outLV.flashswf = swfTxt.text;

outLV.flashstat = statTxt.text;

//send method is POST by default

outLV.sendAndLoad("http://www.mypage.co.uk/writer.php",inLV,"POST");

}

 

This is the text that is being written:

 

<?xml version=\"1.0\" encoding=\"UTF-8\"?><holder><pagestatus holdstatus=\"hold\" filelink = \"mymovie.swf\" /></holder>

 

All the double quotes are being written as \" which is the escape character instead of the actual character - anyone know why this is happening and how I can fix it? Any help will be greatly appreciated!

 
Replies
  • Currently Being Moderated
    Feb 24, 2011 8:03 AM   in reply to Kwangle

    What happens if you escape the d. quotes in your code?

     

    So, instead of txt2 = '" filelink = "';

    txt2 = '\" filelink = \"';

     
    |
    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