[英]How do I read the summary out of an XML file
我想獲取.dll文件的xml文件的注釋。
我正在構建一個代理類創建器(通過接口讀取一個.dll(通過反射)->實現接口),現在我認為擁有接口的方法和參數的標頭會很好,但是我不知道不知道如何
謝謝您的回答,請原諒我的英語不好和較差的編碼知識。
我找到了解決方案:
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;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.