4 Replies Latest reply on Nov 28, 2008 9:25 PM by dcjava

    Debugging XML Variables with Watch Expressions

    dcjava

      I have a Flex Demo application that I'm trying to debug. There is a variable defined as follows:

      var itemToUpdate:XMLList

      If I add a trace statement as follows, I'm able to see the value of the quantity displayed in the Console:

      trace(itemToUpdate.qty); <-- This works!

      But if I add a "Expression" in the debugger like this: "itemToUpdate.qty". I get the following value displayed in the "Expressions" debugging view: "<errors during evaluation>".

      What am I doing wrong? Why can't I add watch expressions for an XMLList type?

      Version: Flex 2.01
        • 1. Re: Debugging XML Variables with Watch Expressions
          Level 7

          "dcjava" <webforumsuser@macromedia.com> wrote in message
          news:ggp5uu$ndd$1@forums.macromedia.com...
          > I have a Flex Demo application that I'm trying to debug. There is a
          > variable
          > defined as follows:
          >
          > var itemToUpdate:XMLList
          >
          > If I add a trace statement as follows, I'm able to see the value of the
          > quantity displayed in the Console:
          >
          > trace(itemToUpdate.qty); <-- This works!
          >
          > But if I add a "Expression" in the debugger like this:
          > "itemToUpdate.qty".
          > I get the following value displayed in the "Expressions" debugging view:
          > "<errors during evaluation>".
          >
          > What am I doing wrong? Why can't I add watch expressions for an XMLList
          > type?
          >
          > Version: Flex 2.01

          http://flexdiary.blogspot.com/2008/03/debugger-and-e4x.html


          • 2. Re: Debugging XML Variables with Watch Expressions
            ctzn99 Level 1
            As Amy pointed out, the flex watch debugger can't evaluate e4x expressions, you can however assign the value to a string and watch the string. This won't allow you to change the e4x value on the fly if that is your goal but it's still useful for just seeing what gets assigned without setting breakpoints and manually digging through the list of properties for the value you want. If you're evaluating a single xml node and you want to see the whole xml make sure to use the .toXMLString() method.

            assuming qty has a value of 12:

            var val:String = itemToUpdate.qty;
            // implicit cast results in val being "12", same as itemToUpdate.qty.toString()

            but

            var val:String = itemToUpdate.qty.toXMLString();
            // leaves the xml syntax intact on a single node, so val would be "<qty>12</qty>"

            Hopefully I didn't confuse the topic, best of luck.
            • 3. Re: Debugging XML Variables with Watch Expressions
              Level 7

              "ctzn99" <webforumsuser@macromedia.com> wrote in message
              news:ggpj60$9e1$1@forums.macromedia.com...
              > As Amy pointed out, the flex watch debugger can't evaluate e4x
              > expressions, you
              > can however assign the value to a string and watch the string. This won't
              > allow you to change the e4x value on the fly if that is your goal but it's
              > still useful for just seeing what gets assigned without setting
              > breakpoints and
              > manually digging through the list of properties for the value you want.
              > If
              > you're evaluating a single xml node and you want to see the whole xml make
              > sure
              > to use the .toXMLString() method.

              You can also use ctrl+f in the Variables window to find specific variables.
              You have to make sure that the category you expect to find it in is
              expanded, but this helps find variables more quickly without "digging."


              • 4. Re: Debugging XML Variables with Watch Expressions
                dcjava Level 1

                Thanks Amy / Zach!

                I'll just have to keep this e4x limitation in mind when I'm debugging.