Using C#, how can we pull attribute values from an XML Schema file and output that onto a CSV file?

后端 未结 2 1147
执念已碎
执念已碎 2020-12-22 11:17

I am trying to pull the attribute values for each of the element, that is in this XMl Schema file.

2条回答
  •  被撕碎了的回忆
    2020-12-22 12:06

    you can use System.Xml.Linq to get all the elements and the required attributes as below

            XDocument document = XDocument.Load(@"D:\New Text Document.xml");
            var eleCollection = document.Elements("element");
    
            foreach (var element in eleCollection)
            {
                var type = element.Attribute("Type").Value;
            }
    

提交回复
热议问题