I have a xml file as below
<?xml version="1.0" encoding="utf-8" ?>
<ConnectionParams xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<configuration>
<loginId1>id 1</loginId>
<loginPass1>passwd 1</loginPass1>
<loginId2>id 2</username>
<loginPass2>passwd 2</loginPass2>
</configuration>
</ConnectionParams>
I have to get the value of each loginPass from a c# program. Can you suggest how to do this. I have just started working with c#.
Thanks.
答案 0 :(得分:0)
您可以使用linq to xml。
var loginpass = from l in xdoc.Descendants("configuration")
select new {
loginPass1 = l.Attribute("loginPass1").Value
};