2 Replies Latest reply on Oct 7, 2010 1:38 AM by Emanuele Radaelli

    [CS5 - JS] Setting XML attributes from variables...

    Emanuele Radaelli Level 1

      Hi,

      I build an XML variable in order to store informations I need to run my script.

      The XML structure is quite simple:

       

      var document = new XML("<document><pages><page/></pages></document>");

       

      All "page" nodes are appended using a simple for statement.

      If I need to append an attribute to a "page" node I usually use this method:

       

      document.pages.page.@height= 210;

       

      What if I need to append an attribute without knowing its name (because it is stored in a variable)?

      Is there a something like this?:

       

      document.pages.page.setAttribute(var_name, 210);

       

      Have no idea how to handle this...