Mam poniżej kodu java, trzeba konwertować te w języku C#, uprzejmie mi pomóc ..SAXParser odpowiednik w C#
public class Configuration {
private ConfigContentHandler confHandler;
public Configuration() {
}
public boolean parseConfigFile() throws Exception {
boolean bReturn = true;
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
System.out.println("*** Start parsing");
try {
confHandler = new ConfigContentHandler(100);
// Configuration file must be located in main jar file folder
// Set the full Prosper file name
String sConfigFile = "configuration.xml";
// Get abstract (system independent) filename
File fFile = new File(sConfigFile);
if (!fFile.exists()) {
System.out.println("Could not find configuration file " + sConfigFile + ", trying input parameters.");
bReturn = false;
} else if (!fFile.canRead()) {
System.out.println("Could not read configuration file " + sConfigFile + ", trying input parameters.");
bReturn = false;
} else {
parser.parse(fFile, confHandler);
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Input error.");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("*** End parsing");
return bReturn;
}
Dzięki
PO chce tylko do odczytu konfiguracji, ale z korzyścią dla innych, którzy są zainteresowani SAX parsowania: Można generalnie nie * * symulować parser SAX z XmlReader ponieważ koncepcje Sax są różne: SAX daje mi „otwarty element tag "nawet jeśli dokument jest zniekształcony i nigdy się nie zamyka. XmlReader udostępnia cały poddrzewa dopiero po jego przeczytaniu i dlatego musi być kompletny. Jest jeszcze jeden port SAX [tutaj] (https://github.com/rasmusjp/sax.net), ale nie jestem pewien, ile to jest warte. – John