Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
edmacdonald #1
Member since Nov 2007 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: Element.HasChildElements returns true if element has text node but no elements
Hi Alexander,

There is a bug in Element.HasChildElements will return true if an element only contains a text node:

            public bool HasChildElements
            {
                  get
                  {
                        if (this.ChildNodes.Count > 0)
                        {
                              return true;
                        }
                        else
                        {
                              return false;
                        }
                  }
            }


Here is a fix:

            get
            {
                           foreach (Node node in this.ChildNodes)
                                if (node.NodeType == NodeType.Element)
                                     return true;
               
                           return false;

            }

It is causing a NullReferenceException in MethodResponse for certain IQ packets:

                if (value.HasChildElements)
                {
                    Element next = value.FirstChild;
                    if (next.TagName == "string")

Here is a snippet of an IQ packet.  Note the space in the value element:

<methodResponse><params><param><value><struct><member><name>error_string</name><value> </value>…



-Ed
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi Ed,

thanks for the fix, this will be in the next release.

Alex
Alexander Gnauck
AG-Software
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP SDK Support RSS