2 Replies Latest reply on Nov 29, 2006 1:11 AM by ceetah

    get the attributes NAME and VALUE from an XML

    ceetah Level 1
      I really love this forum :)

      I load an XML an populate a Tree, from which I start to drag items.
      the xml looks like this:
      <myTag attrName="attrValue" otherAttrName="otherAttrValue"/>

      var ds:DragSource = event.dragSource;
      var var1:String =(event.dragInitiator as Tree).value.@attrName;
      -> the var1 variable has now: "attrValue"

      my question is.. how can I get all the attributes' names? in this example: attrName and otherAttrName (suppose I don't know the structure of that xml node)
      what about attributes values?
      thank you!
        • 1. Re: get the attributes NAME and VALUE from an XML
          ntsiii Level 3
          The snippet below takes an xml node(nodeCur), loops over the attributes list and builds an array that contains the attribute name and value for each attribute. It comes from a sample app that allows you to edit an xml file.
          Sorry that the forum will remove the formatting

          var aDPAttributes:Array = new Array();
          var xlAttributes:XMLList = nodeCur.@*;
          var attribute:Attribute;
          for ( var i:int = 0; i < xlAttributes.length(); i++) {
          aDPAttributes.push({name:xlAttributes [ i ] .name(),value:xlAttributes [ i ] });
          }
          dgAttributes.dataProvider = aDPAttributes; //set the property sheet dataProvider

          Tracy
          • 2. Re: get the attributes NAME and VALUE from an XML
            ceetah Level 1
            thank you very much! worked great.
            name() .... I didn't know about that! :-D