OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] DTD parser in c#

[ Lists Home | Date Index | Thread Index ]


> 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




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS