Hi all,
Please help me to the following:
I use the XML connector to read an XML file. It works fine.
My question is how can I take the attributes of a specific node?
For example, in the following simple XML how can I take the attrubutes of the
node PARIS/George directly?
Thanks in advance
<node label='PARIS'>
<node label='John' tel='12345' fax='67890'/>
<node label='George' tel='12345' fax='67890'/>
</node>
<node label='Rome'>
<node label='John' tel='12345' fax='67890'/>
<node label='George' tel='12345' fax='67890'/>
</node>
Moonster - 22 Oct 2006 20:17 GMT
If you are just reading a XML file - try use the XML class instead.
With that, browse thru your XMLNode's and get the attributes like this:
var node:XMLNode = ...
trace(node.attributes["tel"]);
or:
trace(node.attributes.tel);
- Magnus
> Hi all,
> Please help me to the following:
[quoted text clipped - 13 lines]
> <node label='George' tel='12345' fax='67890'/>
> </node>
prisama - 26 Oct 2006 13:13 GMT
hi,
this is right. Cause the XML Connector is made for use in combination with
components.
But of course u can use the XMLConnector class like so:
import mx.data.components.XMLConnector;
var myXML:XMLConnector = new XMLConnector();
var xcListener:Object=new Object();
xcListener.result=function(evtObj:Object){
var theXML:XML=evtObj.target.results; //note: "results"
var RootNode:XMLNode = theXML.firstChild;
trace(RootNode.nodeName);
}
myXML.addEventListener("result",xcListener);
myXML.URL="dasdadasd.xml";
myXML.direction = "receive";
myXML.ignoreWhite=true;
myXML.trigger();