AS3: How to get all XML-Nodes with a special attribute? (With sourch)

Posted by insnet on Stack Overflow See other posts from Stack Overflow or by insnet
Published on 2009-08-20T20:47:14Z Indexed on 2010/05/09 20:18 UTC
Read the original article Hit count: 146

Filed under:
|
|

Hi there

The Challenge:

i d like to collect all nodes with the attribute "id".

The Problem:

The code doenst work with nested nodes.

<?xml version="1.0" encoding="utf-8"?><contentmap><fonts id="fonts">

fonts/Arial.swf swf/library_main.swf

  private function onXMLLoader(event : Event) : void {

_xml = _loader.getXML(event.target.url.url);

var searchTerms : XMLList = _xml.*.(hasOwnProperty('@id'));

if (searchTerms.length() > 0 ) { _NodeArray = new Array(); _parseNode(searchTerms); }

  private function _parseNode(xml : XMLList) : void {

for each (var node: XML in xml) { if(!node.hasSimpleContent()) { _parseNode(node.children()); } else { var nodeObject : Object = new Object(); nodeObject['value'] = node.text();

 for each(var a:XML in node.@*) {
  var name : String = String(a.name());
  nodeObject[name] = a.toXMLString();
 }
 _NodeArray.push(nodeObject);
}

} }

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flash