[Flashcoders] quotes in XML

2006-08-08 Thread Elie Zananiri

Hello all,

I have an XML parsing question that I've been trying to solve for a little
while now and I can't get it to work.  I have a PHP script that loads text
from an SQL db, formats it in an XML string and sends this string back to
Flash using the LoadVars.sendAndLoad(script.php) function.  This text that
I send can be pretty much anything, including quotes and brackets and I
cannot get Flash to read the XML properly.

I tried encoding the string as ASCII characters ( becomes #34;) or using
XML encoding ( becomes quot;), but since both these encodings use the
ampersand () and since LoadVars returns variables in the MIME format, the
ampersand is interpreted as the split between 2 variables.  Right now, I
managed to get the XML string intact to Flash using url-encoding ( becomes
%22), but Flash automatically decodes these symbols and I get an error when
I create an XML object using the string.

Is there a way to re-encode the string before creating an XML tree from it?
Is there a better way to do what I am trying to do?

Thanks for the help!

--
Elie Zananiri
http://www.prisonerjohn.com
http://www.digital-spa.com
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] quotes in XML

2006-08-08 Thread Steven Sacks | BLITZ
Character substitution, perhaps?

Use pipes |  perhaps.

Then, in Flash...

myLoadedString.split(|).join(\);

___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] quotes in XML

2006-08-08 Thread Elie Zananiri

Thanks, that worked!

I actually XML-encoded the string in PHP using pipes instead of ampersands
and then converted the pipes back to ampersand in Flash once the string was
received.  The conversion from XML-encoding to regular characters is done
automatically.

**
in PHP:
$string = pipe_encode($string);
echo sentStr=.$string.;

function pipe_encode($str) {
 $encoded = ;

 // encode each character one at a time
 for ($i=0; $i  strlen($str); $i++) {
   $currChar = substr($str, $i, 1);

   switch ($currChar) {
 case '':
   $encoded .= |lt;;
   break;
 case '':
   $encoded .= |gt;;
   break;
 case '':
   $encoded .= |amp;;
   break;
 case '\'':
   $encoded .= |apos;;
   break;
 case '':
   $encoded .= |quot;;
   break;
 default:
   $encoded .= $currChar;
   }
 }

 return $encoded;
}

in Flash:
var myXML:XML = new XML(loadedString.split(|).join());
**

On 8/8/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:


Character substitution, perhaps?

Use pipes |  perhaps.

Then, in Flash...

myLoadedString.split(|).join(\);

___
Flashcoders@chattyfig.figleaf.com
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





--
Elie Zananiri
http://www.prisonerjohn.com
http://www.digital-spa.com
___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] quotes in XML

2006-08-08 Thread Sebastian Wichmann

Hi,

try this:

?php echo sentStr=.rawurlencode($string).; ?

Flash:
unescape(string);

Regards,
Sebastian Wichmann

-Ursprüngliche Nachricht- 
Von: Elie Zananiri [EMAIL PROTECTED]

An: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Gesendet: Dienstag, 8. August 2006 20:28
Betreff: Re: [Flashcoders] quotes in XML



Thanks, that worked!

I actually XML-encoded the string in PHP using pipes instead of ampersands
and then converted the pipes back to ampersand in Flash once the string 
was

received.  The conversion from XML-encoding to regular characters is done
automatically.

**
in PHP:
$string = pipe_encode($string);
echo sentStr=.$string.;

function pipe_encode($str) {
 $encoded = ;

 // encode each character one at a time
 for ($i=0; $i  strlen($str); $i++) {
   $currChar = substr($str, $i, 1);

   switch ($currChar) {
 case '':
   $encoded .= |lt;;
   break;
 case '':
   $encoded .= |gt;;
   break;
 case '':
   $encoded .= |amp;;
   break;
 case '\'':
   $encoded .= |apos;;
   break;
 case '':
   $encoded .= |quot;;
   break;
 default:
   $encoded .= $currChar;
   }
 }

 return $encoded;
}

in Flash:
var myXML:XML = new XML(loadedString.split(|).join());
**

On 8/8/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:


Character substitution, perhaps?

Use pipes |  perhaps.

Then, in Flash...

myLoadedString.split(|).join(\);

___
Flashcoders@chattyfig.figleaf.com
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





--
Elie Zananiri
http://www.prisonerjohn.com
http://www.digital-spa.com
___
Flashcoders@chattyfig.figleaf.com
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



___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] quotes in XML

2006-08-08 Thread ryanm

I actually XML-encoded the string in PHP using pipes instead of ampersands
and then converted the pipes back to ampersand in Flash once the string 
was

received.  The conversion from XML-encoding to regular characters is done
automatically.

   Another solution would be to use the XML object in Flash, and either XML 
encode the data or use the CDATA block in the XML. It would be more robust 
and flexible, not to mention more compatible with other client and server 
technologies.


ryanm 


___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] quotes in XML

2006-08-08 Thread David Rorex

On 8/8/06, Elie Zananiri [EMAIL PROTECTED] wrote:

Hello all,

I have an XML parsing question that I've been trying to solve for a little
while now and I can't get it to work.  I have a PHP script that loads text
from an SQL db, formats it in an XML string and sends this string back to
Flash using the LoadVars.sendAndLoad(script.php) function.  This text that
I send can be pretty much anything, including quotes and brackets and I
cannot get Flash to read the XML properly.


Wait...is there any particular reason you are using LoadVars instead
of the XML class? I think simply using XML instead would solve your
problem, without any funny hacks.

-David R
___
Flashcoders@chattyfig.figleaf.com
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


[Flashcoders] Quotes in XML always require CDATA?

2006-05-30 Thread Merrill, Jason
Does it HAVE to be a CDATA node in order to safely include double
quotes in an XML file?  

Be nice if I could do the following, but it's obvious why it breaks:

item title=This is my String with quotes/ 

I'm using iso-8859-1 encoding in the XML, but I think UTF would be OK
too.  I'm grabbing it with xfactorstudios Xpath.  I guess I could look
for single quotes and swap that out for double quotes, but that's not
ideal.  

Thanks,

Jason Merrill
Bank of America 
Learning Technology Solutions
 


 
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Quotes in XML always require CDATA?

2006-05-30 Thread Dave Watts
 Does it HAVE to be a CDATA node in order to safely include 
 double quotes in an XML file?  

Yes, to include any unescaped XML metacharacters, you must place them within
a CDATA block.

 Be nice if I could do the following, but it's obvious why it breaks:
 
 item title=This is my String with quotes/ 
 
 I'm using iso-8859-1 encoding in the XML, but I think UTF 
 would be OK too.  I'm grabbing it with xfactorstudios Xpath.  
 I guess I could look for single quotes and swap that out for 
 double quotes, but that's not ideal.

Why not just escape the characters?

item title=This is my quot;Stringquot; with quotes/

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Quotes in XML always require CDATA?

2006-05-30 Thread Merrill, Jason
Why not just escape the characters?
item title=This is my quot;Stringquot; with quotes/

Good idea.  Exactly what I was looking for.  :)

Jason Merrill
Bank of America 
Learning Technology Solutions
 
 
 
 
 
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Dave Watts
Sent: Tuesday, May 30, 2006 1:25 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Quotes in XML always require CDATA?

 Does it HAVE to be a CDATA node in order to safely include
 double quotes in an XML file?

Yes, to include any unescaped XML metacharacters, you must place them
within
a CDATA block.

 Be nice if I could do the following, but it's obvious why it breaks:

 item title=This is my String with quotes/

 I'm using iso-8859-1 encoding in the XML, but I think UTF
 would be OK too.  I'm grabbing it with xfactorstudios Xpath.
 I guess I could look for single quotes and swap that out for
 double quotes, but that's not ideal.

Why not just escape the characters?

item title=This is my quot;Stringquot; with quotes/

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

___
Flashcoders@chattyfig.figleaf.com
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
___
Flashcoders@chattyfig.figleaf.com
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