Photo of Words

XML line breaks and ampersands.

A short bit of info that I've learned.

By: Jeremy Knight

Ok, so I'm perpetually stumbling when it comes to line breaks and ampersands in XML when being read into flash. Here's the deal:


Line breaks:
Use 
every where you want a line break. works perfectly in both html text fields and non-html text fields.


Ampersands:
Use & where you want an ampersand, but it must be an HTML text field.


I think I'll start just using htmlText fields everywhere from now on. Seems to be no point in using non-html text fields.



Josh

So, it looks like your code for the special characters was just interpreted by the browser. I wonder what happens if you wrap it with a code tage. I'll try:

Is an ampersand showing, ir the code: &



Josh

Or, maybe you have to put the special character code in quotes, and then tell people to remove the quotes. Let's try:

"&" and " "



Josh

That was a dumb idea.



Still Josh

Maybe using the keyboard tag?

&



Josh

Or, what about this? Here the code I typed is:

& a m p ; a m p ;

But without the spaces turns into:

&



Josh

Cool, so let's try the other code Jeremy gave me with a similar approach - typing the code twice except for the initial ampersand. Only type that once - like this (but without the spaces):

& # x D ; # x D ;

Renders as:




Josh

Wait a minute, I think this might be the rule:

& a m p ; # x D ;

You write the code for ampersand and then the remaining text, I guess because it only renders once it renders the ampersand first and then just adds the rest of the text. So the above code now renders as:



That took a disappointing amount of time to figure out.