Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-21-2004, 12:20 PM   #1
punjab4833
Registered User
 
Join Date: Oct 2002
Posts: 19
Send a message via AIM to punjab4833
Default \n not working from XML!??!

I'm pulling in text from an XML file which is being loaded into the variable of a Dynamic Text field. For some reason it will not evaluate any \n as a new line. I just replaced the code with "test\nthis\nout\nnow" instead of the variable I've gotten the XML data from, and it correctly displays each word on a new line.

Does anyone know how to get \n's to correctly evaluate to a new line when pulling them in from an XML file??!?!
punjab4833 is offline   Reply With Quote
Old 01-21-2004, 02:46 PM   #2
punjab4833
Registered User
 
Join Date: Oct 2002
Posts: 19
Send a message via AIM to punjab4833
Default

In case anyone was wondering about this, here's how I fixed the problem:

When the text is pulled in from the xml file, it seems like a "\n" is put in properly, but when displayed in the textfield, it doens't automatically interpret it as a new line.

So to fix it, I did the following (assuming the variable 'bodyText' has the text pulled into it from the XML file) :

*****
txt = bodyText.split("\\n");
bodyText = "";
for(i = 0; i < btxt.length; i++) {
bodyText += btxt[i] + "\n";
}

*****

you have to split the variable of all \n instances, but in the split, you must escape the backslash, so split("\\n") does the trick!
punjab4833 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:59 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.