Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with insertChildAfter for xml in actionsctipt 3
    text
    copied!<p>I'm having a lot of trouble with inserting a child after an existing node that is VERY nested in my XML. I'm trying to insert another IObject node beneath object3_LIST3.</p> <p>I've tried the same scheme as <a href="https://stackoverflow.com/questions/189033/having-trouble-with-insertchildbefore-and-insertchildafter-in-as3">Having trouble with insertChildBefore and insertChildAfter in AS3</a> with this. This always outputs undefined and I can't seem to figure out why.. Can anyone help?</p> <p>If I trace contentNode and parentNode, it outputs:</p> <pre><code>object3_LIST3 </code></pre> <p>and </p> <pre><code>&lt;objects&gt; &lt;IObject&gt;object3_LIST3&lt;/IObject&gt; &lt;/objects&gt; </code></pre> <p>As if no changes were made at all to the document...</p> <pre><code>var contentNode:XML = xml.Menu.menuArr.HeadMenuItem[1].subMenu.subMenuItem[1].objects[0]; var parentNode:XML = xml.Menu.menuArr.HeadMenuItem[1].subMenu.subMenuItem[1].objects.IObject[0]; xml = parentNode.insertChildAfter( contentNode, xmlString ); trace(xml); </code></pre> <hr> <pre><code>&lt;PandemicMenu&gt; &lt;Menu&gt; &lt;menuArr&gt; &lt;HeadMenuItem&gt; &lt;subMenu&gt; &lt;IObject&gt; object1_LIST1 &lt;/IObject&gt; &lt;IObject&gt; object2_LIST1 &lt;/IObject&gt; &lt;IObject&gt; object3_LIST1 &lt;/IObject&gt; &lt;/subMenu&gt; &lt;/HeadMenuItem&gt; &lt;HeadMenuItem&gt; &lt;subMenu&gt; &lt;IObject&gt; object1_LIST2 &lt;/IObject&gt; &lt;subMenuItem&gt; &lt;objects&gt; &lt;IObject&gt; object2_LIST2 &lt;/IObject&gt; &lt;/objects&gt; &lt;/subMenuItem&gt; &lt;subMenuItem&gt; &lt;objects&gt; &lt;IObject&gt; object3_LIST3 &lt;/IObject&gt; Want to insert new IObject here &lt;/objects&gt; &lt;/subMenuItem&gt; &lt;/subMenu&gt; &lt;/HeadMenuItem&gt; &lt;/menuArr&gt; &lt;/Menu&gt; &lt;/PandemicMenu&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload