2 Replies Latest reply on Oct 29, 2009 10:26 AM by SiHoop

    XMLListCollection addItem problem

    SiHoop Level 1

      If I create an arrayCollection and try to add an item using the following code, everything works:

         peopleColumn.addItem({teacherID: "240", password: "secret", first_name: "first", last_name: "last", email: "email address", login_name: "aaa", user_name:"bbb"})

       

      However, if I change the arrayCollection to an XMLListCollection, I get the following error when I try to add an item using the same code.

      Can anyone provide any insight into how I might resolve the problem?

       

      Error: Incorrect type. Must be of type XML or a XMLList that contains one XML object.

        • 1. Re: XMLListCollection addItem problem
          _Natasha_ Level 4

          Hi,

          if you use XMLListCollection you can only add XML data.

          Like this:

          peopleColumn.addItem(<teacher teacherID="240" password="secret" first_name="first" last_name="last" email="email address" login_name="aaa" user_name="bbb"/>);

          1 person found this helpful
          • 2. Re: XMLListCollection addItem problem
            SiHoop Level 1

            Thanks very much for your input. I modified your recommendation as follows: I used an xml object that adds an item to the XMLListCollection.

             

                var newItem:XML=new XML
            newItem=<newTeacher>
              <teacherID>{indexVal}</teacherID>
              <password>{teacherPassword.userPassword}</password>
              <first_name>{firstName.text}</first_name>
              <last_name>{lastName.text}</last_name>
              <email>{eMail.text}</email>
              <login_name>{lastName.text+indexVal}</login_name>
              <user_name>{lastName.text+", "+firstName.text}</user_name>
            </newTeacher>

             

                peopleColumn.addItem(newItem)