The first time I attempted to parse an attribute from a node, my trace returned me nothing. The sample XML provided in AS3.0 documentation was behaving as expected, but my IQ XML node wouldn't return me what I was looking for. And there no error message too. After a couple of unsuccessful attempts, I just closed the file and forgot about it.
Today I decided to give it another shot, and opened it up again. After a little examination of the IQ packet, I realized that the query node had an xmlns attribute in it. Duh! I wasn't handling the namespace :P
A quick search returned me this article by Darron. http://www.darronschall.com/weblog/archives/000223.cfm. So I went ahead and handled the xmlns as he mentioned in his article, and bingo! it works. Thanks Darron!
So if you are parsing jabber iq packets, remember to handle the xmlns.
var req:XML = <iq type="get" id="01" to="xxx.xxxxx.com">
// I had to add this
namespace ns= "xxx:iq:xxx"
use namespace ns;
Yea, I know the AS3 XIFF library would most probably handle it all, but there were reasons why I cannot use the XIFF library for this purpose.