[Mono-bugs] [Bug 499970] New: Xmlnode attribute and inertext seem broken

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 30 19:51:46 EDT 2009


           Summary: Xmlnode attribute and inertext seem broken
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: surfzoid2002 at yahoo.fr
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:
Gecko/2009032803 Mandriva/ (2009.1) Firefox/3.0.8

A simple parsing function don't give the same result under win/.Net and

Reproducible: Always

Steps to Reproduce:
1. use the folowing code without the "item.Attributes != null &&" in the if,
with the XML example i give,to feed a treeview, you will have an "Object
reference not set to an instance of an object "

        public static TreeNode XmlToTreeNode(string leXml)


            TreeNode Result = null;



                XmlDocument doc = new XmlDocument();


                XmlNode RootNde = doc.ChildNodes.Item(0);

                if (string.IsNullOrEmpty(RootNde.Name) == false) Result = new

                foreach (XmlNode CurNode in RootNde.ChildNodes)


                    if (string.IsNullOrEmpty(CurNode.Name) == false)


                        TreeNode Nde = new TreeNode(CurNode.Name);

                        Nde.Tag = CurNode.InnerText;

                        if (CurNode.Attributes.Count > 0)


                            string AttrName = CurNode.Attributes[0].Name;

                            string AttrVal = CurNode.Attributes[0].InnerText;

                            TreeNode ChildNde = null;

                            for (int i = 0; i < CurNode.Attributes.Count; i++)


                                ChildNde = new

                                ChildNde.Tag = CurNode.Attributes[i].InnerText;




                        foreach (XmlNode item in CurNode.ChildNodes)


                            TreeNode Nde2 = new TreeNode(item.Name);

                            Nde2.Tag = item.InnerText;

                            if (item.Attributes != null &&
item.Attributes.Count > 0)


                                string AttrName2 = item.Attributes[0].Name;

                                string AttrVal2 = item.Attributes[0].InnerText;

                                TreeNode ChildNde2 = null;

                                for (int i = 0; i < item.Attributes.Count; i++)


                                    ChildNde2 = new

                                    ChildNde2.Tag =










            catch (Exception Ex)


                Console.WriteLine("{0} {1} {2}",
Ex.Message,Environment.NewLine, Ex.StackTrace);

                TreeNode Err = new TreeNode("Error");

                return Err;


            return Result;


XML data example to use :
<email>tittiatcoke at gmail.com</email>
<realname>Raymond Wooninck</realname>
<project name="KDE:KDE4:Factory:Desktop"/>
<project name="KDE:KDE4:UNSTABLE:Desktop"/>
<project name="openSUSE:Factory"/>
<project name="openSUSE:Factory:Contrib"/>
Actual Results:  
see the screenshot when using "item.Attributes != null &&" to prevent first
monobug and see the "extra" "#text".

Expected Results:  
no more "Object reference not set to an instance of an object " and "extra"
"#text" to display same result as windows/.Net

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list