|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: DTD parser in c#
> Could you please share sample coding how to read a file into SAX.NET?
Sure, here it is (from memory, not tested):
IXMLReader reader = new KDS.Xml.Expat.ExpatReader();
// or if a default parser is configured:
// IXMLReader reader = SAXReaderFactory.CreateReader(null);
FileStream fileStm = new FileStream(myFileName, FileMode.Open, FileAccess.Read);
// maybe turn namespaces on
reader.SetFeature(System.Xml.Sax.Constants.namespacesFeature, true);
// set call-back handlers
reader.ErrorHandler = myErrorHandler;
reader.ContentHandler = myContenthandler;
IProperty declProp = reader.GetProperty(
System.Xml.Sax.Constants.declHandlerProperty);
declProp.Value = myDeclhandler;
IProperty lexProp = reader.GetProperty(
System.Xml.Sax.Constants.lexicalHandlerProperty);
lexProp.Value = myLexicalhandler;
// process the file
try {
reader.Parse(new StreamInputSource(fileStm));
}
finally {
fileStm.Close();
}
Karl
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








