I came across this on the web a while back:

 //original author http://www.wolfenhex.com
 public static function format(node, tab):String {
  if (tab == undefined) tab = "";
  if(node.nodeName == null) return format(node.firstChild, tab);
  var s:String = "<" + node.nodeName;
  for(var a:String in node.attributes) s += " " + a + "=\"" +
node.attributes[a]+ "\"";
  if(!node.hasChildNodes()) {
   s += " />";
   return tab + s + newline;
  }
  s += ">";
  if(node.firstChild.nodeType == 3) s += node.firstChild.nodeValue;
  else {
   s += newline;
   for(var i:Number = 0; i < node.childNodes.length; i++) s += format(
node.childNodes[i], tab + "\t");
   s += tab;
  }
  s += "</"+node.nodeName+">";
  return tab + s + newline;
 }

Just throw an xml node at it and see what happens.

Jim Kremens


On 1/9/06, Jobe Makar <[EMAIL PROTECTED]> wrote:
>
> Hi Sander,
>
> Thanks, but modifying the source XML is not an option in this case. I am
> just looking for something that will take the XML and convert it to a
> string
> with whitespace. I'll probably just need to write something to do it.
>
> Jobe Makar
> http://www.electrotank.com
> http://www.electro-server.com
> phone: 919-609-0408
> mobile: 919-610-5754
> fax: 919-341-8104
> ----- Original Message -----
> From: "Sander" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" <[email protected]>
> Sent: Monday, January 09, 2006 2:14 PM
> Subject: Re: [Flashcoders] adding whitespace back into xml
>
>
> > Why don't you just include html tags in your XML, so it becomes  XHTML?
> > You just take a couple of nodes and use them to set the  htmlText
> property
> > of a textfield?
> >
> > <myData>
> > <node type='XHTML-content'>
> > <p>
> > <ul>
> > <li>Bullet 1</li>
> > <li>Bullet 2</li>
> > </ul>
> > <p>
> > <br/>
> > <p>Some other paragraph</p>
> > </node>
> > </myData>
> >
> > var myText.htmlText = xmlObject.firstChild.childNodes.toString();
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



--
Jim Kremens
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to