これが私の方法です
private void ParseXML()
{
int pubid = 1;
settings.DtdProcessing = DtdProcessing.Parse;
using (reader = XmlReader.Create(FileName, settings))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name.Trim().ToLower())
{
case "book":
book = new Book();
book.Pubid = pubid;
book.Pubtype = "book";
book.Pubkey = reader.GetAttribute("key");
ParseBook(reader, book);
pubid++;
break;
case "article":
article = new Article();
article.Pubid = pubid;
article.Pubkey = reader.GetAttribute("key");
article.Pubtype = "article";
ParseArticle(reader, article);
pubid++;
break;
case "incollection":
incollection = new Incollection();
incollection.Pubid = pubid;
incollection.Pubkey = reader.GetAttribute("key");
ParseIncollection(reader, incollection);
pubid++;
break;
case "inproceedings":
inproceeding = new Inproceedings();
inproceeding.Pubid = pubid;
inproceeding.Pubtype = "inproceeding";
inproceeding.Pubkey = reader.GetAttribute("key");
ParseInproceedings(reader, inproceeding);
pubid++;
break;
}
}
}
}
}
このファイルを解析しています。http://dblp.uni-trier.de/xml/
ただし、他のパーサーで xml を確認したところ、incollections 要素が xml にあるようです。
ただし、このコードを実行すると、ケース「incollection」が発生しません。その他は正常に動作します。
これは 1.2Gb の xml ファイルです。
デバッグは in collection = new incollection にも当たらないのでエラーなし