Reputation: 2930
I have .xml like this:
<Type>
<Connections>
<Conn ServerName="serv1" DataBase="Persons" User="admin" Pass="123"/>
<Conn ServerName="serv2" DataBase="Type123" User="admin" Pass="123"/>
</Connections>
<UDLFiles>
<UDL Path="C:\Test.UDL>
</UDLFiles>
</Type>
and I want to save all the ServerNames in string[] ServerNames;
all the DataBases in string[] DataBases;
and so on... How to get all these Atributes of this XML?
I try it with:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNodeList conn = xmlDoc.GetElementsByTagName("Conn");
foreach (XmlNode item in conn)
{
//item.Attributes;
}
but I cant get Atributes with this code... Any ideas?
Upvotes: 1
Views: 219
Reputation: 2028
Cast to XmlElement instead of XmlNode. Then you can use the Attributes property.
Upvotes: 5