Skip navigation
cosmicvibs
Currently Being Moderated

probleme copying XML: nodes please help

Dec 19, 2009 1:35 PM

hi here is my simple script:

i dont understand why my templist:XMLList doesnt work:

 

var Pages:XML=<Pages />;
Pages.page = <page />;
Pages.page.@id="5";
Pages.page.adverts=<adverts />;
Pages.page.adverts.adfile=<adfile />;
Pages.page.adverts.adwidth=<adwidth />;
Pages.page.adverts.adheight=<adheight />;
Pages.page.adverts.adposx=<adposx />;
Pages.page.adverts.adposy=<adposy />;

 

Pages.page.adverts.adfile="yoyo";
Pages.page.adverts.adwidth="2";
Pages.page.adverts.adheight="3";
Pages.page.adverts.adposx="6";
Pages.page.adverts.adposy="8";

 

var templist:XMLList= Pages.page.adverts.copy();
templist[0].adfile="yiyi";
templist[0].adwidth="56";
templist[0].adheight="568";
templist[0].adposx="1078";
templist[0].adposy="2005";
Pages.page.adverts.insertChildBefore(Pages.page.adverts, templist);
trace(Pages);

 

 

IT TRACE IN THE OUTPUT THIS

<Pages>
  <page id="5">
    <adverts>
      <adfile>yoyo</adfile>
      <adwidth>2</adwidth>
      <adheight>3</adheight>
      <adposx>6</adposx>
      <adposy>8</adposy>
    </adverts>
  </page>
</Pages>

 

INSTEAD OF TRACING THAT :

<Pages>
  <page id="5">
    <adverts>
      <adfile>yoyo</adfile>
      <adwidth>2</adwidth>
      <adheight>3</adheight>
      <adposx>6</adposx>
      <adposy>8</adposy>
    </adverts>

<adverts>
       <adfile>yiyi</adfile>
       <adwidth>56</adwidth>
       <adheight>568</adheight>
       <adposx>1018</adposx>
       <adposy>2005</adposy>
     </adverts>
  </page>
</Pages>

 
Replies
  • Currently Being Moderated
    Dec 19, 2009 1:44 PM   in reply to cosmicvibs

    Pages.page.appendChild(templist)

     

    thsi will append it as you wish

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2009 1:56 PM   in reply to cosmicvibs

    The command you used would have placed it before the original entry if it were coded correctly...

     

    Pages.page.insertChildBefore(Pages.page.adverts[0], templist);

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2009 1:57 PM   in reply to cosmicvibs

    lol no problem.

    Happy Holidays


     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points