本文整理汇总了C#中XmlReader.ReadToFollowingElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadToFollowingElement方法的具体用法?C# XmlReader.ReadToFollowingElement怎么用?C# XmlReader.ReadToFollowingElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadToFollowingElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItems
// Enumerates over all items in the Project Gutenberg catalog. If you need the creation
// date you must get it by calling the GetCreated method before this one. The returned
// items can be either meta-data for books or files (book volumes). Books come first.
public IEnumerable<object> GetItems(XmlReader reader)
{
Log.Verbose("Getting items...");
while (reader.ReadToFollowingElement())
switch (reader.LocalName) {
case "etext":
// The number is parsed within the ParseBook method. This copy is for logging
// purposes only.
var number = int.Parse(reader.GetAttribute("ID", RDF).Substring(5),
CultureInfo.InvariantCulture);
Book book;
using (var subreader = reader.ReadSubtree())
try {
book = ParseBook(subreader);
} catch (Exception exception) {
throw new ApplicationException(string.Format(
"Parsing book {0} failed.", number), exception);
}
yield return book;
break;
case "file":
// The URL is parsed within the ParseVolume method. This copy is for logging
// purposes only.
var url = ParseVolumeUrl(reader);
Volume volume;
using (var subreader = reader.ReadSubtree())
try {
volume = ParseVolume(subreader);
} catch (Exception exception) {
throw new ApplicationException(string.Format(
"Parsing volume {0} failed.", url), exception);
}
yield return volume;
break;
}
}