Mailing List
Home
Flash Pro
Extending Flash
Flash Macromedia Developer
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
SV: [Flashcoders] Recursive xml function

SV: [Flashcoders] Recursive xml function

2004-02-25       - By Wallgren Jonatan

 Back
Reply:     1     2     3  

I don 't know if this will help you, but this extension saves the
nodenames of an xmlnode as properties of the node so you can access
nodes like this:

xmlObject = new
XML( <root > <catalog > <item >1 </item > <item >2 </item > <item >3 </item > <catalog > </
root >);
xmlObject.toObject();
trace(xmlObject.root.catalog.item[0].nodeValue);
//1

The method has some drawbacks, for example if you have a node in your
xml the has the same name of an internal property of the XMLnode object,
the internal property will be overwritten. On the positive side you
don 't have to store the data twice.

XMLNode.prototype.toObject = function() {
   var children = this.childNodes;
   for (var i = 0; i <children.length; i++) {
      if (this[children[i].nodeName] == undefined) {
         this[children[i].nodeName] = children[i];
      } else if (this[children[i].nodeName].length =undefined) {
         this[children[i].nodeName] = new
Array(this[children[i].nodeName]);
      }
      if (this[children[i].nodeName] instanceof Array) {
         this[children[i].nodeName].push(children[i]);
      }
      if (children[i].hasChildNodes()) {
         children[i].toObject();
      }
   }
}

Jonatan


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:105195
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)