当前位置: 首页>>代码示例>>C#>>正文


C# XmlReader.ReadToFollowingElement方法代码示例

本文整理汇总了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;
         }
 }
开发者ID:prantlf,项目名称:Gutenberg,代码行数:39,代码来源:CatalogParser.cs


注:本文中的XmlReader.ReadToFollowingElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。