private void button1_Click(object sender, EventArgs e)//保存信息到xml
        {
            XmlDocument mydoc = new XmlDocument();
            if (!File.Exists("test.xml"))
            {
                XmlDeclaration xmldec = mydoc.CreateXmlDeclaration("1.0", "GB2312", null);
                mydoc.AppendChild(xmldec);                XmlElement xmlelem = mydoc.CreateElement("info");
                mydoc.AppendChild(xmlelem);                mydoc.Save("test.xml");                mydoc.Load("test.xml");                XmlElement xmle = mydoc.CreateElement("aboutinfo");                xmle.SetAttribute("A", "" + textBox1.Text + "");
                xmle.SetAttribute("B", "" +pname.Text + "");//第二个textbox值                XmlElement allex = mydoc.DocumentElement;
                allex.AppendChild(xmle);                mydoc.Save("test.xml");            }
            else
            {
                mydoc.Load("test.xml");
                XmlNode xmlnode = mydoc.SelectSingleNode("info");
                XmlNode xmllist = xmlnode.FirstChild;
                XmlElement ex = (XmlElement)xmllist;
                ex.SetAttribute("A", "" + textBox1.Text + "");
                ex.SetAttribute("B", "" + pname.Text + "");                mydoc.Save("test.xml");
            }
        }        private void button5_Click(object sender, EventArgs e)//打开xml
        {            XmlDocument mydoc = new XmlDocument();            mydoc.Load("test.xml");            XmlNode xmlnode = mydoc.SelectSingleNode("info");            XmlNode xmlno = xmlnode.FirstChild;
            XmlElement ex = (XmlElement)xmlno;
            textBox1.Text = ex.GetAttribute("A");
            pname.Text = ex.GetAttribute("B");        }
报错提示是
未处理 System.NullReferenceException
  Message="未将对象引用设置到对象的实例。"
  Source="MJZXT"
  StackTrace:
       在 MJZXT.doctor.button1_Click(Object sender, EventArgs e) 位置 E:\门急诊信息系统开发\MJZXT\doctor.cs:行号 195
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 MJZXT.Program.Main() 位置 E:\门急诊信息系统开发\MJZXT\Program.cs:行号 18
       在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()我的textbox有值,每次都到  mydoc.Load("test.xml");
                    XmlNode xmlnode = mydoc.SelectSingleNode("info");
                    XmlNode xmllist = xmlnode.FirstChild;
                    XmlElement ex = (XmlElement)xmllist;
                    ex.SetAttribute("A", " + textBox1.Text", "");
就出错啦,