Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Extra line breaks in text loaded from XML

Engaged ,
Nov 16, 2007 Nov 16, 2007
Hello all,
So I am loading some text from an XML file. It is a couple of lines, and it loads fine. But, the line breaks show up as more than one break. Actually, it seems like Flash sees it as one large line break or something. For example ...

<?xml version="1.0" encoding="utf-8"?>
<myData>
First Line
Second Line
Third Line
</myData>

... would show up as what looks like triple spaced lines. I was messing around with the ignore white space, but in AS3 that is supposed to be off by default I think. Plus I am not sure that even applys to what I am doing. Ideas?

- B
TOPICS
ActionScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 16, 2007 Nov 16, 2007
Its OS dependent. The XML was probably created in a windows editor.

Windows standard is two characters for a line break. Carriage return+LineFeed.
That's not the same as other OSes which use one (either CR or LF).
Flash seems to use either CR or LF to make a line break.
You can filter them like this
if myNode represents one of your myData nodes...
var stringVal = myNode.firstChild.nodeValue; //text node value
stringVal = stringVal.split("\r\n").join("\r");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 16, 2007 Nov 16, 2007
actually that was as2 so you might need to translate it for the XML stuff for as3, can't remember the differences off hand.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 16, 2007 Nov 16, 2007
Was wondering why it wasn't working... I am VERY new to AS3 - like a few days, so I am not sure of the translation. I'll work it though. Thanks a lot.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 16, 2007 Nov 16, 2007
LATEST
no problem. Looks like it will be next week for me to really put in a solid start with as3 now. I had a play with the as3 xml a few months back to compare with as2 and it absolutely rocks.. I just can't remember the details now.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines