Asp tutorial. net c Read and Write File Operation Code
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 .");
}
}
}
// Simple
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 );
}
%>