Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-09-2012, 09:41 AM   PM User | #1
bryanbelle
New to the CF scene

 
Join Date: Aug 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
bryanbelle is an unknown quantity at this point
XML line break

Hi,

I have a new problem with my XML parsed to AS3 textfield. Seems like there is a double spacing line break when displayed on the Flash AS3 screen from the XML file. below is my code in the XML, i did try <br /> but to now avail since the <br /> tag will display itself on the textfield.

XML code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<pages>
<page pTitle="What Causes Back Pain?">
Poor posture
Strenuous activities at home or at work
Lifting, carrying, pushing or pulling incorrectly
Standing or bending down for long periods
Twisting or bending awkwardly
Sitting in a hunched position for long periods without taking a break
Muscle tension and or over-stretching
</page>
</pages>


And this my AS3 Code:
var myXML:XML = new XML();
var XMLURL:String = "xxxx.xml";
var myXMLURL:URLRequest = new URLRequest(XMLURL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void
{
myXML = XML(event.target.data);
titleText.text=myXML.page[0].@pTitle;
descText.htmlText=myXML.page[0];
}

Any help would be much appreciated.

Thanks,

BB
bryanbelle is offline   Reply With Quote
Old 08-11-2012, 05:20 AM   PM User | #2
shufflestumps
New Coder

 
Join Date: Aug 2012
Posts: 11
Thanks: 0
Thanked 3 Times in 3 Posts
shufflestumps is an unknown quantity at this point
Hi bryanbelle

I believe I may have joined the site the same day as yourself and therefore I should probably leave this part to the moderators, however I just thought I'd let you know that you will probably recieve considerably more assistance if you follow the forum rules as found here:

http://www.codingforums.com/showthread.php?t=101113

I am making this comment in relation to code sequences being inserted into code tags for easy viewing by the members of the forum.

As for your problem, I have to say that I have not done any work with XML working with Flash, however the XML "code" that you have posted seems incomplete to me - ie: what XML tags are you using for your child elements?

Example:
Code:
<line>Poor posture</line>
<line>Strenuous activities at home or at work</line>
<line>Lifting, carrying, pushing or pulling incorrectly</line>
<line>Standing or bending down for long periods</line>
<line>Twisting or bending awkwardly</line>
<line>Sitting in a hunched position for long periods without taking a break</line>
<line>Muscle tension and or over-stretching</line>
I don't profess to be an expert on this matter as I have only recently learned XML myself, but it seems to me that as per your "code" you have posted, if this is how it actually appears then it is my opinion that your document is not well formed in the sense that your child elements each need an opening and closing line attribute.

"Each XML element MUST have an opening and closing tag and each element MUST be opened and closed in the correct order for the document to be well formed"

Maybe this is your problem?

I had the same problem as you at one stage whilst writing a document meaning that line breaks are NOT the answer as you are already aware.

Hope I have used the correct terminlogy here and provided some reasonable advice which may assist in solving your problem.

Other respondees: I have no problem with being corrected in regard to any of my statements which prove to be false and/ or the terminology used. I want to learn also.
shufflestumps is offline   Reply With Quote
Old 08-11-2012, 11:29 PM   PM User | #3
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
I'm no expert myself, but understand that XML line-breaks are preserved and could be viewed in the resultant HTML using View Source.

In JS you could use the function nl2br to re-establish the breaks and, hopefully, there is an equivalent function in AS:

Code:
function nl2br(s) { return s.split(/\r?\n/).join("<br>"); }
I apologise if this doesn't prove helpful
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 08-13-2012, 05:04 AM   PM User | #4
shufflestumps
New Coder

 
Join Date: Aug 2012
Posts: 11
Thanks: 0
Thanked 3 Times in 3 Posts
shufflestumps is an unknown quantity at this point
Well that's way more helpful than my reply I believe! Very handy function in PHP and JS - Actionscript equivalent - mmm- seems like a question I'd come up with - you know the ones I mean - answer the first question only to find another question needs answering and then loop - lol - back to Google
shufflestumps is offline   Reply With Quote
Old 08-24-2012, 01:08 PM   PM User | #5
sshover
New to the CF scene

 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sshover is an unknown quantity at this point
If you need more line breaks between elements, I don't believe it's possible to add them through CSS (and using before or after pseudo elements isn't the answer, since it would make it neither a) valid xml (without modifying the XML document), and b) compatible with IE). So if you do need more space, you will have to use margins and padding instead.
read more here
sshover is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 AM.


Advertisement
Log in to turn off these ads.