4 Replies Latest reply on Feb 3, 2011 12:34 AM by vineet osho

    having problem with insertchildAfter

    vineet osho Level 1

      Hi  guys

                   i am working  with xml and want to appending a node after a particular node.i m using insertchildAfter function.but can not able to append that node using that.

      here is the structure of my xml:-

       

      <root>
              <data>
                  <first>burger</first>
                  <second>soda</second>
              </data>
      </root>

       

      i just want to append my node after first.can any body help me out.


      Regards

      Vineet Osho

        • 1. Re: having problem with insertchildAfter
          Flex harUI Adobe Employee

          What does your code look like?

          • 2. Re: having problem with insertchildAfter
            vineet osho Level 1

            hi

                 Thanks For your quick reply.here is my code.and i already sent my xml structure above.

             

            <?xml version="1.0" encoding="utf-8"?>
            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           minWidth="955" minHeight="600"  creationComplete="init()">
                <fx:Script>
                    <![CDATA[
                        import mx.controls.Alert;
                        import mx.rpc.events.ResultEvent;
                        private var xml:XML;
                        private function init():void{
                            httpTest.url = 'data.xml';
                            httpTest.send();
                        }
                        private function resulthandler(ev:ResultEvent):void{
                            xml = ev.result as XML;
                        }
                        protected function button1_clickHandler(event:MouseEvent):void{
                            // TODO Auto-generated method stub
                            xml.insertChildAfter(xml.data.first,<saleItem>fries</saleItem>);
                            Alert.show(xml+'');
                           
                        }

             

                    ]]>
                </fx:Script>
                <fx:Declarations>
                    <s:HTTPService id="httpTest" resultFormat="e4x" result="resulthandler(event)" fault=";"/>
                </fx:Declarations>
                <s:Button label="appened" click="button1_clickHandler(event)"/>
            </s:Application>

             

             

             

            ========================================================================================== ========================

            Waiting for the reply.

             

             

            Thanks And Regards

                 Vineet Osho

            • 3. Re: having problem with insertchildAfter
              Flex harUI Adobe Employee

              The example in the doc indicates that you should use:

               

              xml.data[0].insertChildAfter(xml.data.first[0],);

              • 4. Re: having problem with insertchildAfter
                vineet osho Level 1

                Thanks a ton it works for me.