4 Replies Latest reply on May 27, 2009 2:01 AM by *Prashant Shelke*

    dynamically change xml attributes




      I have teh following xml

      xml = <books>

           <book name="book 1" author="author 1" price="50 USD"/>



      I have the following array


      var arr = ["name", "book new", "author", "author new", "price", "10 USD"];


      var is dynamically generated so I do no know the order of the attributes. The only thing I know is that the array definitely has its elemenst in a [attName, attValue, attName, attValue, attName, attValue...] way. The size of array is also not known in advance.


      now I am trying ot do something like -


      for(var i=0;i<arr.length;i+2){

           xml.books.book.attribute(arr[i]) = arr(i+1);



      and it throwing the following error -

      Target of assignmnet must be a reference value.


      How do i get around this? Any help greatly appreciated. Thanks,