一聚教程网:一个值得你收藏的教程网站

热门教程

asp.net c读取写文件操作代码

时间:2022-06-25 05:07:13 编辑:袖梨 来源:一聚教程网

asp教程.net c读取写文件操作代码

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.io;
using system.xml.schema;
using system.collections.generic;
using system.xml;
namespace xmlaa
{
  public class readxml
  {
  public static void main()
  {
  xmlreadersettings setting = new xmlreadersettings();
  //insert template.
  setting.schemas.add(null,@"....po.xsd");
  //validate.
  setting.validationtype = validationtype.schema;
  //does not handle errors, but displays an error message.
  setting.validationeventhandler += new 
  validationeventhandler(evenhandler);
   
  xmlreader reader = xmlreader.create(@"....vol.xml",setting);
  while (reader.read())
  {
  if (reader.nodetype == xmlnodetype.text)
  {
  console.writeline(reader.value);
  }
  }
  console.readline();
  }

  public static void evenhandler(object sender, validationeventargs e)
  {
  //error message
  console.writeline("the method or operation is not implemented.");
  }
  }
}

// 简单一点的

using (filestream fs = new filestream(file, filemode.open,fileaccess.readwrite))
            {
                xmldocument toxml = new xmldocument();
                toxml.load(fs);
                //do some modification for the xml.
                fs.flush();
                toxml.save(fs);
            }


%>

热门栏目