xml question?

what is the equivalent of this in C# ?

foreach (XmlNode xmlConfigNode in xmlConfigDoc["configuration"].ChildNodes)



Thansk


0
Ray5531 (3)
4/7/2005 6:04:24 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
747 Views

Similar Articles

[PageSpeed] 41

Sorry I made a mistake here is what I want to convert to C#

For Each Node In XmlDocument.Item("configuration").Item("appSettings")

"Ray5531" <Ray5531@microsoft.com> wrote in message 
news:elPIiezOFHA.3408@TK2MSFTNGP14.phx.gbl...
> what is the equivalent of this in C# ?
>
> foreach (XmlNode xmlConfigNode in 
> xmlConfigDoc["configuration"].ChildNodes)
>
>
>
> Thansk
>
> 


0
Ray5531 (3)
4/7/2005 6:16:27 AM
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" <Ray5531@microsoft.com>
>References: <elPIiezOFHA.3408@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: <#$RWRlzOFHA.1096@tk2msftngp13.phx.gbl>
>Newsgroups: microsoft.public.dotnet.xml
>NNTP-Posting-Host: 24.86.17.112
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.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("appSettings")
>
>"Ray5531" <Ray5531@microsoft.com> wrote in message 
>news:elPIiezOFHA.3408@TK2MSFTNGP14.phx.gbl...
>> what is the equivalent of this in C# ?
>>
>> foreach (XmlNode xmlConfigNode in 
>> xmlConfigDoc["configuration"].ChildNodes)
>>
>>
>>
>> Thansk
>>
>> 
>
>
>



0
yingzile (9)
4/26/2005 5:43:24 PM
Reply:

Similar Artilces:

Inline Jpgs and more questions
A few questions: 1. How do you view jpg attachments inline? Similar to Outlook Express. 2. After upgrading to Outlook 2002 from 2000, you cannot even select all, then hit enter to view all in an external viewer. Why does it seem we went backwards? 3. Even the Progress Bar for sending and receiving email is more accurate in Outlook Express. In outlook, it appears it just takes the number of enclosures and divides by that number (immaterial of their size), where OE truly shows progress on the bytes. Very helpfull when using dialup. Why does it seem the free email package is bette...

scanpst.exe questions
Hi, After much hunting, I found scanpst.exe, which I'm told will help me overcome mailbox correuption problem. When I run it, I'm told that .pst that I'm trying to fix does not exisit specifically - despite the fact that when I look at it's details, this 'non-existant" file has 34, 444 bytes in it. Has anyone seen this type of helpful behavior beore and do you have any suggestions about how to out wit it? It all depends on how corrupt the mailbox is, but I've seen situations where putting a null character in the first byte of the file allowed scanpst t...

Brainstorming question
I have an XP box that is set up in an office as an incoming fax, it does not have Norton installed and it is not a server, XP Pro only. The incoming fax folder is shared. We also have a server 08 and each user has a login script that launches the shared fax folder. The users complain that occasionally the shared Fax folder stops responding when they access it from their desk - this is corrected by disconnecting and rebooting their machine. Any ideas on how to fix this non responsive issue or can I run a task that will copy and move the faxes as they come in to the serve...

Question about right click in a CTreeControl!
Hello! Having problems about right clicking on an item in a tree control. The item that is clicked on is not the right one. If I have three items in a tree. Here is my problem. I click on the first item with normal click. I click on the third item with the right click mouse. In this event I had a messagebox telling me which item is selected, and this one comes out with the first item no mather what. I also tried to get into the OnSelchangedItemfieldtree function - but with no luck. How can I right click on the third one and get its name out of it? Does anyone know? -- - Lars I guess u...

Outlook question to challange all you MVP's out there.
I am slowly migrating my users from a single Exchange 2000 box, to a cluster Exchange 2003 server. I have 155 gas stations all over the east coast that have pc's in them with email. My problem is that all the stores are not on my corporate domain. What happens when I launch outlook is it prompts me for the username, password, and domain. Once I enter it in, it logs in fine, and there are no issues. The odd part about this is that on my "old" Exchange 2000 box, it doesn't prompt the user. It just logs them in since their username and password in the store are the same as...

May I post here questions about SQL queries against Excel via ODBC?
and if not, can you recommend of a relevant forum? For example, I'm desperately looking for an answer to the question: How can I retrieve the row number of a record in a query? Somethin like: select x.*,rownum() from sheet1$ as x Thanks in advance, Noam ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com try posting in the Security Forum, under SQL Server Security, that's where most people go when they have questions about SQL. ...

Unusual formatting question
Hi bit of an odd question here.. I have a list of URL's that are currently in an Excel file. The URL' are listed in one column with one on each row, so for example: link1.ac.uk link2.ac.uk link3.ac.uk link4.ac.uk link5.ac.uk What I need to do is merge all of these links into one long line an add a plus sign between them. In the above example this would mean: link1.ac.uk+link2.ac.uk+link3.ac.uk+link4.ac.uk+link5.ac.uk Is there a way of getting Excel (or any other programme) to take th original list and reformat it as above? I have several clusters of links that need to be refo...

database question #2
Creating a database in excel for mailing labels. Fieldnames: Title (Mr. & Mrs.), Fname (John), Lname (Jones), Add, City, etc. Is there a way to handle married people who want to be addressed as: Ms. Sally Smith and Mr. John Doe Is there an alternative field to be set up? Can't figure it out unless it's just a code field and then a manual change. Thanks if there is an easy solution. A field is just a space to contain data, so you can put what you like i it -- Message posted from http://www.ExcelForum.com ...

SOP Form Question
We have several customers that require we put a Department on their invoice. One customer has about 10 and the other one has about 50. I have create a Department field on the User Defined form and if click the hour glass you can see all 60 departments. My question: is there a way to setup an Xref somewhere that would filter the dropdown values that would be associated to each customer? The issue is that a user may inadvertently select a department that is not valid for that customer. I am trying to make this as much idiot proof as possible. Any suggestions would be welcomed. T...

Something wrong when xml control is not showing data
This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C60F88.8BCE9BA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I am using VB/ASP.net 2005. When I click submit it refreshes the page = without entering the data from all the text boxes and not entering in = the Game1.xml. here is the asp.vb code Imports System.Xml Partial Class _game1 Inherits Web.UI.Page ............... Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As = System.EventArgs) Handles btnSubmit.Click Dim xDoc As New XmlDocum...

reading and writing xml using a tcp stream
Hi, I am writing a client/server application with a desktop and a pocketPC which transfers a xml string which is to be loaded by a dataset on the client. the server uses this code to prepare and send the xml: Dim stringbuilder As New StringBuilder Dim textwriter As StringWriter = New StringWriter(stringbuilder) Dim xmltextwriter As New Xml.XmlTextWriter(textwriter) xmltextwriter.Formatting = Xml.Formatting.Indented Dataset.WriteXml(xmltextwriter, XmlWriteMode.WriteSchema) 'this is the connection to the client Dim w As New IO.StreamWriter(mobjClient.GetStream) ' the &qu...

if statement question #2
How do I do this using an if statement in excel? If the amount is from 15000-350000 then the tax is .23, if its extactly 350000 then its .15 What I really need to know if theres something similar to "to" in the if statement. For example 15000 to 350000 like in a c++ switch statement. -- SMAlvarez ------------------------------------------------------------------------ SMAlvarez's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=33287 View this thread: http://www.excelforum.com/showthread.php?threadid=531129 Assuming there isn't more to it than...

simple question about BSTR and CString
Hello! If we pass a BSTR parameter named bstrIDs into a method and in this method we do CString cstrIDs = bstrIDs; what does this mean ? Does it mean that cstrIDs is pointing to the same memory as bstrIDs is poining to ? Is it correct that when you use CString you don't have to allocate memory ? //Tony Tony Johansson wrote: > Hello! > > If we pass a BSTR parameter named bstrIDs into a method and in this > method we do CString cstrIDs = bstrIDs; > what does this mean ? > > Does it mean that cstrIDs is pointing to the same memory as bstrIDs is > poining to ?...

Question for "application-defined or object-defined error" retrieve outlook contact
Hello, I used the VB to retrieve the outlook XP contact list. When I run the application, it prompt a dialog box. In the following is the dialog box message: A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No". When I click "Yes", the screen prompt out "Error 287: Application-defined or object-defined error". In normally, if click "Yes", the VB program can retrieve all contact records out, but in my case, it flows this error. Any exp...

Neophyte question regarding CDialog
I have an app whose main window is created using a class derived from CDialog. I want the user to be able to run the app in UI mode and in batch mode. In UI mode, the dialog is displayed normally using DoModal. In batch mode, I would like to still create the dialog but make it hidden. I plan to issue WM_COMMAND messages to the dialog to invoke various functions already implemented by the app. My problem right now is with hiding the dialog. How can I make the dialog hidden before it ever gets displayed? I looked at CWnd::PreCreateWindow but found out that it does not get called fo...

A question about Exchange 2003 direct-push technology in the UK
Hi, I'm just trying to get my head around exactly how Exchange 2003 direct-push actually works. Currently I have a blackberry server which acts as a link between our Exchange server and Vodafone. In order to set up Exchange direct-push (instead of blackberrys) does this work in a similar way? Ie, if we have a Vodafone account does Exchange push the email out to their network which then forwards it on to the device? Or does our Exchange server have to be externally visible on the Internet and the devices have to be configured to communicate with the server directly? Has anyone who&...

Sendobject Question
I am trying to use a datepicker to set number of days until an email reminder is sent. I am a little over my head. I am trying to use something like: If me.date_picker.value <> now() then dateadd("d"(me.datepicker.value ????? docmd.sendobject ....... I don't know how to set this up with dateadd or something else if the user wants an email reminder, say, 30 days from now and they select that date on the datepicker. Am I just way off track? Thanks so much!!! -- Milton Purdy ACCESS State of Arkansas Ok first point date time pickers can be hard to control, as ...

2 Part Question
Hi, I'm looking to be able to type 2 lines of text in a single cell. Each time I press "enter" my cursor goes to the next cell. Is there a way to do this. Next. I'm trying to create a reservation book for my restaurant. I have the form all setup the way I like it but I was wondering if there is a way to set the date in a cell so that when I print each page will have a different date. Sort of like a calendar. Thank you, John Bordieri Hi John use Alt+Enter instead of Enter and this will insert a line feed. With regard to dates, putting =TODAY() in a cell will inser...

Xml Serialization #7
Hey There I have a couple of collections that I've written that are based upon the HybridDictionary. Initially I recieved an exception when attempting to serialize instances of these collections informing me that I needed to implement an Add(System.Object) method because the collections inherit from IEnumerable. "You must implement the Add(System.Object) method on PrecisionObjects.Collections.Specialized.StringDictionaryEx because it inherits from IEnumerable." Once I recieved that exception I thought of implementing the IXmlSerializable interface directly however it i...

Upgrade question
Hi I'm planning on upgrading both my OS ( to OS X 10.4.1 ) and my Office ( to 2004 ) at the same time. I'm planning to wipe my drive and update everything from scratch. My question is regarding updating the Office Professional installation. Will I need to install the earlier versions of Office and Virtual PC to make this go? I own Office X and Connectix Virtual PC 6 and have purchased the Office Professional upgrade. I'd prefer to not have to install the earlier versions if I can avoid it. Thanks Claude In article <d7finv$vrn$1@bolt.sonic.net>, claudel@bolt.sonic.net...

suggested ways to manipulate XML files in .Net?
Hi everyone, I'm going to manipulate some XML files in my next project-- crawl through the tags, compare if file X has the same nodes as file Y, and if not, what the differences are and who's missing what. I'll also be comparing values between nodes in the two files, for when both documents do have the same named nodes. What .Net classes should I be looking at to accomplish these tasks? Thanks a bunch. Steve Hershoff wrote: > I'm going to manipulate some XML files in my next project-- crawl through > the tags, compare if file X has the same nodes as file Y, and...

SQL Server 2005 CAL question
If I have 1 HQ Server with with 2 HQ Clients, how many CALS do I need at the HQ server. Thanks in advance. Phil get a min of 5 cals Its not only the clients to think about its also any office PC that connects to SQL. "Phil V" <PhilV@discussions.microsoft.com> wrote in message news:3E2F3590-032F-4B4C-9CEC-5A6A6BC7F46D@microsoft.com... > If I have 1 HQ Server with with 2 HQ Clients, how many CALS do I need at > the > HQ server. Thanks in advance. > > Phil ...

create automatic response to questions in excel....
Hi, Is there a way in excel where I have 10 questions and can click on one question and get the answer to pop up in my spreadsheet? thank you, Felicia On Dec 1, 6:39 am, felicia <feli...@discussions.microsoft.com> wrote: > Hi, > Is there a way in excel where I have 10 questions and can click on one > question and get the answer to pop up in my spreadsheet? > > thank you, > > Felicia One way, with questions in A1:A10 and corresponding correct answers in A1:A10 on a hidden worksheet with tab name "Answers"... right click the tab of the sheet with the qu...

xml doc
I have three image groups. I have to create an XML document that models the image groups.Each grouping should include the name and location of the images within the group. How can I do that? seema wrote: > I have three image groups. I have to create an XML document that models the > image groups.Each grouping should include the name and location of the images > within the group. > > How can I do that? What exactly are you looking for, some XML structure to mark up the information? Or for concrete .NET code to create the XML? -- Martin Honnen --- MVP XML http://Jav...

simple .net xml serialization not working
I have a type in a schema: <xs:complexType name="SimpleExt"> <xs:simpleContent> <xs:extension base="xs:int"> <xs:attribute name="name" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType> which I run xsd.exe /c on. It creates the following class: /// <remarks/> public class SimpleExt { /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string name; /// <remarks/> [System.Xml.Serializat...