c# - 如何从 XML 文件中读取摘要

标签 c# xml

我想获取.dll文件的xml文件的注释。

我正在构建一个代理类创建器(读取其中包含接口(interface)的 .dll(通过反射)--> 实现接口(interface)),现在我认为拥有方法的 header 和接口(interface)的参数会很好,但我不知道怎么做。

感谢您的回答,请原谅我糟糕的英语和糟糕的编码知识。

最佳答案

我找到了一个解决方案:

   private static void ReadTheSummarys()
    {
      XmlReader xmlReader = XmlReader.Create("Test.xml");
      bool isSummary = false;
      while (xmlReader.Read())
    {
    //checks if the current node is a summaray
    if (xmlReader.Name == "summary")
    {
      isSummary = true;
      continue;
    }

    if (isSummary)
    {
      //Replace and trim for pure Comments without spaces and linefeeds
      string summary = xmlReader.Value.Trim().Replace("\n", string.Empty);
      if (summary != string.Empty)
      {
        //Writes the pure comment for checking
        Console.WriteLine(summary);           
      }
    isSummary = false;
    }

    }

    }

关于c# - 如何从 XML 文件中读取摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22246127/

相关文章:

c# - 仅保护条款需要单元测试吗?

c# - .NET Core 应用程序中的 .NET Framework 依赖项

xml - 如何将XML文件从HDFS加载到HBase表

xml - 您可以转换无序的 xml 以匹配 xsd :sequence order?

xml - 如何使用 xml 配置 log4j 1.2

c# - Entity Framework - groupby 和时间跨度计算

c# - 从 .NET 中的数据库图像列将多个文件附加到电子邮件

每个连接字符串运行 C# 集成测试

xml - Perl:从 XML 输出填充数组(通过 Eutils 的 PubMed UID)

xml - 将 Sql 表转换为 XML