本文介紹了使用 C#,我們如何從 XML Schema 文件中提取屬性值并將其輸出到 CSV 文件中?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試提取每個元素的屬性值,即在此 XMl Schema 文件中.
I am trying to pull the attribute values for each of the element, that is in this XMl Schema file.
推薦答案
這是一種最簡單的方法,可以在節點上使用 for 循環來獲取每個節點中的信息.使用 node.ChildNodes 屬性來獲取 chilenodes.
This is easiest way one can use for loops on nodes to get the information in each node. use node.ChildNodes property to get the chilenodes.
XmlDocument doc = new XmlDocument();
doc.Load("filepath");
//Here Path could be- "http://ElementType" ---> this will give all nodes with name ElementType
XmlNodeList nodes= doc.SelectNodes("http://give path of nodes you want attributes for");
foreach (XmlNode node in nodes)
{
//Assuming you want information of element tags
foreach (XmlNode child in node.ChildNodes)
{
string name= node.Attributes["type"].Value;
string name= node.Attributes["label"].Value;
}
}
這篇關于使用 C#,我們如何從 XML Schema 文件中提取屬性值并將其輸出到 CSV 文件中?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!