Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Bryan Gidge http://www.gidge.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Actionscript _XML Class

   1  
   2  import _String;
   3  
   4  dynamic class _XML extends XML {
   5  	function _XML() {
   6  		
   7  	}
   8  	
   9  	public function $N(tag,xmlNode,xmlNodeArray){
  10  		if (xmlNode == undefined) var xmlNode = this;
  11  		if (xmlNodeArray == undefined) var xmlNodeArray:Array = new Array();
  12  		var nodeArray:Array = new Array();
  13  		
  14  		for (var x=0; x<xmlNode.childNodes.length; x++) {
  15  			if (xmlNode.childNodes[x].nodeType == 1){
  16  				if (xmlNode.childNodes[x].nodeName == tag) xmlNodeArray.push(xmlNode.childNodes[x]);
  17  				$N(tag,xmlNode.childNodes[x],xmlNodeArray);
  18  			}
  19  		}
  20  		return xmlNodeArray;
  21  	}
  22  	
  23  	// If multiple, returns a nodeValue Array
  24  	// If single, returns a nodeValue String
  25  	public function $V(tag,xmlNode) {
  26  		if (xmlNode == undefined) var xmlNode = this;
  27  		var n = $N(tag,xmlNode);
  28  		if (n.length == 1){
  29  			var nV = n[0].firstChild.nodeValue;
  30  			if (nV != undefined){
  31  				nV = escape(nV);
  32  				nV = _String.Replace(nV,"%C2%93","%22");
  33  				nV = _String.Replace(nV,"%C2%94","%22");
  34  				nV = unescape(nV);
  35  			}
  36  			return nV;
  37  		}
  38  		else {
  39  			var vArray:Array = new Array();
  40  			for (var i:String in n) {
  41  				vArray[i] = n[i].firstChild.nodeValue;
  42  				if (vArray[i] != undefined){
  43  					vArray[i] = escape(vArray[i]);
  44  					vArray[i] = _String.Replace(vArray[i],"%C2%93","%22");
  45  					vArray[i] = _String.Replace(vArray[i],"%C2%94","%22");
  46  					vArray[i] = unescape(vArray[i]);
  47  				}
  48  			}
  49  			return vArray;
  50  		}
  51  	}
  52  }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS