XMLファイルを読み取ってWebページに表示したいのですが、forループで表示できません
XmlDocument doc = new XmlDocument();
doc.Load(@"c:/xmldatabase.xml");
XmlElement root = doc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("//User");
foreach (XmlNode node in nodes)
{
Label1.Text = node["Name"].InnerText;
Label3.Text = node["Contact"].InnerText;
Label4.Text = node["Email"].InnerText;
Label2.Text = node["City"].InnerText;
Label5.Text = node["Country"].InnerText;
}
私のXMLにはデータがあります!
<?xml version="1.0"?>
<User-Profile>
<User>
<Name>Jhon</Name>
<Contact>4567897632</Contact>
<Email>pri@dfdcm.com</Email>
<City>xyz</City>
<Country>abc</Country>
</User>
<User>
<Name>Mike</Name>
<Contact>8888888</Contact>
<Email>acvb@dfdcm.com</Email>
<City>xrtty</City>
<Country>abffff</Country>
</User>
<User>
<Name>Stone</Name>
<Contact>875467</Contact>
<Email>dfttgh@dfdcm.com</Email>
<City>dfvbnj</City>
<Country>ddccvv</Country>
</User>
</User-Profile>
ループなどを使用してすべてのデータを表示し、これらのデータをWebページのラベルに割り当てたいのですが可能ですか?これを行う方法?