Hi Ray,
Assume you have a XML file(config.xml) looks like this:
<root>
<configuration id=>
<appSettings/>
<appSettings/>
....
</configuration>
<configuration id=>
<appSettings/>
<appSettings/>
....
</configuration>
</root>
So the C# code to iterate the appSettings would look like this:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("config.xml");
XmlNodeList configNodes = xmlDoc.SelectNodes("//configuration");
//iterate each configuration node
foreach (XmlNode cfgNode in configNodes)
{
XmlNodeList appSettingNodes = cfgNode.SelectNodes("./appSettings");
//iterate each app setting of current configuration Node
foreach(XmlNode settingNode in appSettingNodes)
{
..................
}
}
Hope this helps!
Thanks,
--Yingzi Le
LongHorn SDK Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Ray5531" <Ra*****@microsoft.com>
References: <el**************@TK2MSFTNGP14.phx.gbl>
Subject: Re: xml question?
Date: Wed, 6 Apr 2005 23:16:27 -0700
Lines: 18
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <#$**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.xml
NNTP-Posting-Host: 24.86.17.112
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:6473
X-Tomcat-NG: microsoft.public.dotnet.xml
Sorry I made a mistake here is what I want to convert to C#
For Each Node In XmlDocument.Item("configuration").Item("appSetting s")
"Ray5531" <Ra*****@microsoft.com> wrote in message
news:el**************@TK2MSFTNGP14.phx.gbl... what is the equivalent of this in C# ?
foreach (XmlNode xmlConfigNode in
xmlConfigDoc["configuration"].ChildNodes)
Thansk