XML : Is there any way to make my C# XMLManager work?

so I'm a total noob to C# is there any way to make this work? It would also be a great help if someone could explain why my system doesn't work, and why another version would.

  using System;  using System.Xml;    public class XMLManager  {      private XmlTextReader reader;      private XmlDocument document;      private XmlNodeList nodeList;        public void OpenFile(string file)      {          try          {              reader = new XmlTextReader(file);              reader.WhitespaceHandling = WhitespaceHandling.None;              reader.MoveToContent();              document = new XmlDocument();              document.Load(reader);              nodeList = document.SelectNodes(@"Settings/Settings");          }          catch (System.IO.FileNotFoundException)          {          }      }        public void CloseFile()      {          if (reader != null)          {              ((IDisposable)reader).Dispose();              reader.Close();              reader = null;          }          document = null;          nodeList = null;      }        public string Get(string attrib)      {          for (int i = 0; i < nodeList.Count; i++)          {              reader.MoveToAttribute(i);              if (reader.Name == attrib)              {                  return reader.Value;              }          }          return null;      }  }    

Edit: Sorry for my bad formatting, this is my first time posting on Stack Overflow.

No comments:

Post a Comment