【发布时间】:2023-03-03 04:54:22
【问题描述】:
这是我的方法
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 所以没有错误
【问题讨论】:
-
请改进: 1. 包含足够的 XML 引用(该链接包含三个 XML 文件,其中两个太大,无法快速查看)。 2.调试显示什么?
-
@Richard 我已经编辑了问题
-
这有点好,但在问题中嵌入信息(连同已完成的,即可编译的)代码来显示问题要好得多。