xml StreamReader

try 
                { 
                        using   (StreamReader   sr   =   new   StreamReader(fileurl)) 
                        { 
                                XmlDocument   doc   =   new   XmlDocument(); 
                                doc.Load(sr); 
}
                                XmlNode   root   =   doc.DocumentElement; 
                                XmlElement   elem1   =   doc.CreateElement("name"); 
                                elem1.InnerText   =   uname; 
                                XmlElement   elem2   =   doc.CreateElement("logtime"); 
                                elem2.InnerText   =   time; 
                                XmlNode   userelem   =   doc.CreateNode(XmlNodeType.Element,   "user",   ""); 
                                userelem.AppendChild(elem1); 
                                userelem.AppendChild(elem2); 
                                root.AppendChild(userelem); 
                                doc.Save(fileurl); 
                                doc   =   null; 
                               
                        
                } 
                catch   (Exception   ex) 
                {   } 

posted @ 2008-04-22 21:09  风轻如梦  阅读(658)  评论(0编辑  收藏  举报