2 Replies Latest reply on Apr 3, 2009 9:21 AM by Newsgroup_User

    httpservice object/string problem

    Juan_Jiménez
      What I am doing is simply callling an XML to display some pictures. If the result XML is:
      <images>
      <image>assets/images/pic1.jpg</image>
      <image>assets/images/pic2.jpg</image>
      </images>

      ...then I can access result object in result event handles with references like
      event.result['images']['image'][0].toString();
      This line for example, returns assets/images/pic1.jpg.

      The problem is that, if my XML have only one child, like:
      <images>
      <image>assets/images/pic1.jpg</image>
      </images>

      ...then the result es not an object, i can't use event.result['images']['image'][0].toString(); cause event.result['images']['image'] is returned as String and not as object.

      Does anyone know the reason of the behaviour?
        • 1. Re: httpservice object/string problem
          Gregory Lafrance Level 6
          Ensure your resultFormat is e4x and do this:

          • 2. Re: httpservice object/string problem
            Level 7

            "????6" <webforumsuser@macromedia.com> wrote in message
            news:gr34lc$8b0$1@forums.macromedia.com...
            > What I am doing is simply callling an XML to display some pictures. If the
            > result XML is:
            > <images>
            > <image>assets/images/pic1.jpg</image>
            > <image>assets/images/pic2.jpg</image>
            > </images>

            > ...then I can access result object in result event handles with references
            > like
            > event.result['images']['image'][0].toString();
            > This line for example, returns assets/images/pic1.jpg.
            >
            > The problem is that, if my XML have only one child, like:
            > <images>
            > <image>assets/images/pic1.jpg</image>
            > </images>

            > ...then the result es not an object, i can't use
            > event.result['images']['image'][0].toString(); cause
            > event.result['images']['image'] is returned as String and not as
            > object.
            >
            > Does anyone know the reason of the behaviour?

            Try

            event.result.child('images').child('images').child(0).text();

            If you're never going to have anything other than <image> tags in <images>,
            try:

            event.result.child('images').child(0).text();