Hi there Jobe,
Try this. It works great for me.
class util.XMLFormat {
public static function formatXML(p_xml:XMLNode, p_tab:String):String {
p_tab = (p_tab == undefined) ? "\t" : p_tab;
var str:String = new String();
var nodeValue:String = p_xml.nodeValue;
var nodeName:String = p_xml.nodeName;
if ((nodeValue != null) && (nodeValue != undefined)) {
str += p_tab + nodeValue + "\n";
} else if (nodeName != null) {
str += p_tab + "<" + nodeName;
var attr:Object = p_xml.attributes;
for (var n:String in attr) {
str += " "+ n +"=\""+attr[n]+"\"";
}
if (p_xml.firstChild != null) {
if (p_xml.firstChild.nodeValue != null) {
str += ">" + checkCDATA(p_xml.firstChild.nodeValue) + "</" + nodeName+
">\n";
} else {
str += ">\n";
var children:Array = p_xml.childNodes;
var l:Number = children.length;
for (var i:Number=0; i<l; i++) {
str += formatXML(children[i], "\t"+p_tab);
}
str += p_tab + "</" + nodeName + ">\n";
}
} else { str += " />\n"; }
}
return str;
}
public static function checkCDATA(p_str:String):String {
var tempStr:String = new XML("<![CDATA[" + p_str + "]]>").toString();
return (tempStr.indexOf("&") != -1) ? "<![CDATA[" + p_str + "]]>" : p_str;
}
}
Cheers,
Dimitrios
----- Original Message -----
From: "Jobe Makar" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Monday, January 09, 2006 9:21 PM
Subject: Re: [Flashcoders] adding whitespace back into xml
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
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders