Re: [Flashcoders] xml whitespace problem
XML.ignoreWhite = true; XML.load - Original Message - From: "david kraftsow" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" Sent: Tuesday, January 24, 2006 4:34 PM Subject: [Flashcoders] xml whitespace problem Hi. Whats the easiest way to strip out that annoying whitespace from your xml nodes? I have a lovely human-readable xml file with tons of carriage returns and tabs. When I load it into a flash XML object the leaf/content nodes all have tabs and carriage returns in them. Setting the ignoreWhite property does nothing. [?] Example: When I parse out that leaf content I get a string like "\n\n Leaf content" Very annoying. I don't have to write a traversal method to strip it all out do I? Surely there is a better way! DK ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
yeah that does nothing. you would think it would solve the problem but no... JesterXL wrote: XML.ignoreWhite = true; XML.load - Original Message - From: "david kraftsow" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" Sent: Tuesday, January 24, 2006 4:34 PM Subject: [Flashcoders] xml whitespace problem Hi. Whats the easiest way to strip out that annoying whitespace from your xml nodes? I have a lovely human-readable xml file with tons of carriage returns and tabs. When I load it into a flash XML object the leaf/content nodes all have tabs and carriage returns in them. Setting the ignoreWhite property does nothing. [?] Example: When I parse out that leaf content I get a string like "\n\n Leaf content" Very annoying. I don't have to write a traversal method to strip it all out do I? Surely there is a better way! DK ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] xml whitespace problem
JesterXL wrote: > XML.ignoreWhite = true; > XML.load In response but david kraftsow wrote: > Setting the ignoreWhite property does nothing. Bad Jesse! No cookie! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
I've never seen that before. How is the XML being generated? Manual or dynamic? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
Everything within a CDATA is read exactly as is, I believe -- that's the point of using it. whitespace is the whitespace between tags, not within a CDATA text node, so ignoreWhite shouldn't affect it. I think you'll have to butt your text content up against the [ and ] to make it read right. Helen -- http://flash-creations.com http://i-technica.com david kraftsow wrote: yeah that does nothing. you would think it would solve the problem but no... JesterXL wrote: XML.ignoreWhite = true; XML.load - Original Message - From: "david kraftsow" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" Sent: Tuesday, January 24, 2006 4:34 PM Subject: [Flashcoders] xml whitespace problem Hi. Whats the easiest way to strip out that annoying whitespace from your xml nodes? I have a lovely human-readable xml file with tons of carriage returns and tabs. When I load it into a flash XML object the leaf/content nodes all have tabs and carriage returns in them. Setting the ignoreWhite property does nothing. [?] Example: When I parse out that leaf content I get a string like "\n\n Leaf content" Very annoying. I don't have to write a traversal method to strip it all out do I? Surely there is a better way! DK ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
manually.. i typed it by hand in dreamweaver and added the tabs and returns for readability. John Giotta wrote: I've never seen that before. How is the XML being generated? Manual or dynamic? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] xml whitespace problem
> Whats the easiest way to strip out that annoying whitespace > from your xml nodes? > I have a lovely human-readable xml file with tons of carriage > returns and tabs. When I load it into a flash XML object the > leaf/content nodes all have tabs and carriage returns in > them. Setting the ignoreWhite property does nothing. [?] Since whitespace within a CDATA block within an XML node is actually part of its content, I wouldn't expect there to be a way to remove it. I suspect that the ignoreWhite property may strip whitespace between nodes, although I have very little experience working with XML in Flash. 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 mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
i thought that could be the case too.. but then i took the CDATA brackets completely out but left the text.. so its just a floating text node now. it still does the same thing.. =( Helen Triolo wrote: Everything within a CDATA is read exactly as is, I believe -- that's the point of using it. whitespace is the whitespace between tags, not within a CDATA text node, so ignoreWhite shouldn't affect it. I think you'll have to butt your text content up against the [ and ] to make it read right. Helen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] xml whitespace problem
Actually, ignoreWhite works for my CDATA content - if I add retuns like he did, and remove the ignoreWhite, it screws up big time. If I leave ignorewhite on, it renders just fine. Jason Merrill | E-Learning Solutions | icfconsulting.com >>-Original Message- >>From: [EMAIL PROTECTED] [mailto:flashcoders- >>[EMAIL PROTECTED] On Behalf Of Helen Triolo >>Sent: Tuesday, January 24, 2006 4:59 PM >>To: Flashcoders mailing list >>Subject: Re: [Flashcoders] xml whitespace problem >> >>Everything within a CDATA is read exactly as is, I believe -- that's the >>point of using it. whitespace is the whitespace between tags, not >>within a CDATA text node, so ignoreWhite shouldn't affect it. I think >>you'll have to butt your text content up against the [ and ] to make it >>read right. >> >>Helen >> >>-- >>http://flash-creations.com >>http://i-technica.com >> >> >> >>david kraftsow wrote: >> >>> yeah that does nothing. you would think it would solve the problem but >>> no... >>> >>> JesterXL wrote: >>> >>>> XML.ignoreWhite = true; >>>> XML.load >>>> >>>> - Original Message - From: "david kraftsow" >>>> <[EMAIL PROTECTED]> >>>> To: "Flashcoders mailing list" >>>> Sent: Tuesday, January 24, 2006 4:34 PM >>>> Subject: [Flashcoders] xml whitespace problem >>>> >>>> >>>> Hi. >>>> >>>> Whats the easiest way to strip out that annoying whitespace from your >>>> xml nodes? >>>> I have a lovely human-readable xml file with tons of carriage returns >>>> and tabs. When I load it into a flash XML object the leaf/content >>>> nodes all have tabs and carriage returns in them. Setting the >>>> ignoreWhite property does nothing. [?] Example: >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> When I parse out that leaf content I get a string like "\n\n >>>>Leaf content" >>>> Very annoying. I don't have to write a traversal method to strip it >>>> all out do I? Surely there is a better way! >>>> >>>> DK >>> >> >>___ >>Flashcoders mailing list >>Flashcoders@chattyfig.figleaf.com >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] xml whitespace problem
I use Dreamweaver for my XML editing, and have put returns in and have used ignoreWhite with no issues. The ignoreWhite DOES have an effect on the CDATA content (I just did a test and saw it happen). However, I have seen this behavior if some sneaky hidden characters got in somehow, like say a tab or something. For this reason, I don't put spacing in like you have normally, just to be sure. It's really not all that much more difficult to read and gives you some peace of mind. Jason Merrill | E-Learning Solutions | icfconsulting.com >>-Original Message- >>From: [EMAIL PROTECTED] [mailto:flashcoders- >>[EMAIL PROTECTED] On Behalf Of david kraftsow >>Sent: Tuesday, January 24, 2006 5:01 PM >>To: Flashcoders mailing list >>Subject: Re: [Flashcoders] xml whitespace problem >> >>manually.. i typed it by hand in dreamweaver and added the tabs and >>returns for readability. >> >>John Giotta wrote: >> >>>I've never seen that before. How is the XML being generated? Manual or dynamic? >>>___ >>>Flashcoders mailing list >>>Flashcoders@chattyfig.figleaf.com >>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>> >>> >>> >> >>___ >>Flashcoders mailing list >>Flashcoders@chattyfig.figleaf.com >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
you could try setting condenseWhite = true on the textfield that should get rid of the whitespace due to the linebreaks. dunc On 1/24/06, david kraftsow <[EMAIL PROTECTED]> wrote: > > i thought that could be the case too.. but then i took the CDATA > brackets completely out but left the text.. so its just a floating text > node now. it still does the same thing.. =( > > Helen Triolo wrote: > > > Everything within a CDATA is read exactly as is, I believe -- that's > > the point of using it. whitespace is the whitespace between tags, not > > within a CDATA text node, so ignoreWhite shouldn't affect it. I think > > you'll have to butt your text content up against the [ and ] to make > > it read right. > > > > Helen > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
I suspect it's some unwarranted charset sticking some unknown line breaks. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
Thanks all. I think I figured out the problem.. this xml causes the spaces: Leaf content 1 blah blah blah. but this doesnt: Leaf content 1 blah blah blah. I guess that should have been obvious. ignoreWhite only works on spaces between nodes.. not within them. duh. =S DK John Giotta wrote: I suspect it's some unwarranted charset sticking some unknown line breaks. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
I had this exact problem just last week. I couldn't figure out a solution, so I simply removed all carriage returns and tabs from the raw XML data. Here's the function that I wrote to clean things up. Simply add on onData event handler to your XML loading and then call this function with the raw XML data string. I didn't try the condenseWhite option that Duncan suggests, but if that works, I'll kick myself. Either way, this solution works well for me. function cleanXML(xmlString):String{ var cleanString:String = xmlString; // remove any processing instructions in the XML data while (cleanString.indexOf("") + 2; var dirtyString:String = cleanString.slice(startIndex, endIndex); cleanString = cleanString.split(dirtyString).join(""); } // remove any extranieous \t\n\r characters in the XML data cleanString = cleanString.split("\r").join(""); cleanString = cleanString.split("\n").join(""); cleanString = cleanString.split("\t").join(""); return cleanString; } Note that I'm also removing all processing instructions from the XML as well because Flash can't handle them (my clients are using Altova StyleVision to edit the content and that puts an extra processing instruction block at the top of the XML file). Hope that helps, Josh On Jan 24, 2006, at 3:34 PM, david kraftsow wrote: Hi. Whats the easiest way to strip out that annoying whitespace from your xml nodes? I have a lovely human-readable xml file with tons of carriage returns and tabs. When I load it into a flash XML object the leaf/ content nodes all have tabs and carriage returns in them. Setting the ignoreWhite property does nothing. [?] Example: When I parse out that leaf content I get a string like "\n \nLeaf content" Very annoying. I don't have to write a traversal method to strip it all out do I? Surely there is a better way! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] xml whitespace problem
Nice. condenseWhite does work but only if you are just using the xml content in a text field. For my purposes I needed to do conditional stuff based on the xml -- no text fields involved -- so I had to have the exact strings. Josh Gormley wrote: I had this exact problem just last week. I couldn't figure out a solution, so I simply removed all carriage returns and tabs from the raw XML data. Here's the function that I wrote to clean things up. Simply add on onData event handler to your XML loading and then call this function with the raw XML data string. I didn't try the condenseWhite option that Duncan suggests, but if that works, I'll kick myself. Either way, this solution works well for me. function cleanXML(xmlString):String{ var cleanString:String = xmlString; // remove any processing instructions in the XML data while (cleanString.indexOf("") + 2; var dirtyString:String = cleanString.slice(startIndex, endIndex); cleanString = cleanString.split(dirtyString).join(""); } // remove any extranieous \t\n\r characters in the XML data cleanString = cleanString.split("\r").join(""); cleanString = cleanString.split("\n").join(""); cleanString = cleanString.split("\t").join(""); return cleanString; } Note that I'm also removing all processing instructions from the XML as well because Flash can't handle them (my clients are using Altova StyleVision to edit the content and that puts an extra processing instruction block at the top of the XML file). Hope that helps, Josh On Jan 24, 2006, at 3:34 PM, david kraftsow wrote: Hi. Whats the easiest way to strip out that annoying whitespace from your xml nodes? I have a lovely human-readable xml file with tons of carriage returns and tabs. When I load it into a flash XML object the leaf/ content nodes all have tabs and carriage returns in them. Setting the ignoreWhite property does nothing. [?] Example: When I parse out that leaf content I get a string like "\n \nLeaf content" Very annoying. I don't have to write a traversal method to strip it all out do I? Surely there is a better way! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders