XmlTextReader Question

I have the following XML
i do the following to extract the name information 

XmlTextReader Reader =  new XmlTextReader("C:\\names.xml");
while(tempReader.Read() )
{
      if(tempReader.Name.ToLower() == "name ")
      {
                //My problem here how to get firstname and last for the 
current name node    by other words get the childs information from parent 
node
      }

}
<family>
  <name gender="Male">
    <firstname>Tom</firstname>
    <lastname>Smith</lastname>
  </name>
  <name gender="Female">
    <firstname>Dale</firstname>
    <lastname>Smith</lastname>
  </name>
</family>
0
6/8/2005 6:14:03 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
729 Views

Similar Articles

[PageSpeed] 31


Raed Sawalha wrote:

> I have the following XML
> i do the following to extract the name information 
> 
> XmlTextReader Reader =  new XmlTextReader("C:\\names.xml");
> while(tempReader.Read() )
> {
>       if(tempReader.Name.ToLower() == "name ")
>       {
>                 //My problem here how to get firstname and last for the 
> current name node    by other words get the childs information from parent 
> node
>       }
> 
> }
> <family>
>   <name gender="Male">
>     <firstname>Tom</firstname>
>     <lastname>Smith</lastname>
>   </name>
>   <name gender="Female">
>     <firstname>Dale</firstname>
>     <lastname>Smith</lastname>
>   </name>
> </family>

Here is a C# example:

     XmlTextReader xmlReader = new XmlTextReader(@"test2005060801.xml");
     while (xmlReader.Read()) {
       if (xmlReader.NodeType == XmlNodeType.Element &&
           xmlReader.Name == "name")
       {
         Console.Write("Found <name> element: ");
         while (xmlReader.Read()) {
           if (xmlReader.NodeType == XmlNodeType.Element &&
               xmlReader.Name == "firstname")
           {
             Console.Write("first name is: {0}, ", 
xmlReader.ReadElementString());
             Console.WriteLine("last name is: {0}", 
xmlReader.ReadElementString());
             break;
           }
         }
       }
     }
     xmlReader.Close();

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
6/8/2005 12:17:12 PM
Reply:

Similar Artilces:

Loss of Functionality questions
If I understand correctly, sometime in the next month or two I will lose the ability to update stock quotes in MS Money 2003. Will I still be able to download from my banks and brokerages and CheckFree? As far as I know, these connect directly and not via the MSN website. Is there any way, other than manually entering each price, to get quote data into MS Money once the automatic download facility expires? Thanks. It does not seem to me as if the later versions of Money have any features that I would use or have fixed the bugs and annoyances that have appeared over the past years, so I am ...

XmlTextReader Help!!!
Hi, Ok, so here's my problem. I'm trying to read an xml file using an XmlTextReader. The file itself is simple. What I'd like to do is compare each node's value attribute to another string. If they are the same, I'll retrieve the text of the node and do some mumbo-jumbo with it. Here's what my xml file looks like (note that it contains lots more nodes): <Fruits> <fruit value="007">Mango</fruit> <fruit value="010">Pineapple</fruit> <fruit value="489">Tangerine</fruit> <fruit value...

System Restore question
In order to research a problem I'm having (inability to send/receive emails with jpg attachments) with my currently installed IE7/SP3 setup, I have a question. If I uninstall SP3, then uninstall IE7, then reinstall both, and screw it up, will a Restore Point made before I start get me back to proper installations of IE7 and SP3? ( I have a CD for SP3 Thx Dave WnXP IE7, SP3 OE6 Don't you think the problem is with Outlook Express rather than IE7 or SP3? Have you checked the settings in OE? "Dave" <djbahb@dcwis.com> wrote in message news:uQAOX...

AA questions
Hi, I have 3 questions relating to the use of Analytical Accounting: 1) Does AA work with Inventory transactions i.e Inventory adjustment or Inventory Transfer 2) Does AA work at the Purchase PO level or only at the GRV stage before posting - i.e. can you specify AA dimensions against the account on the PO Line window? 3) For takeon transactions ina re-implementation, what is the best way to bring on AA detail? Thanks Neil ...

ESEUTIL Question
Exchange Gods, I have corrupted items in a users mailbox that fails my backup what is the eseutil command I need to use to fix that store. Also one other question: What's the defrag command for the stores and any good way to automate? Thanks, J5 - Eric A. Weintraub Sr. Network Administrator ScriptLogic Corp -- Whats the error message(s)? On Fri, 04 Jun 2004 23:18:10 -0400, Eric Weintraub <ericweintraub@hotmail.com> wrote: >Exchange Gods, > >I have corrupted items in a users mailbox that fails my backup what is the >eseutil command I need to use to fix that st...

Copy and paste question in Excel
Hi, all. I've been having a very strange thing happen when I attempt to copy and paste a date from one sheet to another: even though the cell's formats match each other, the copied date (say it's 2/27/08) always shows up upon pasting as one day and four years later (in this instance, 2/28/12). Any idea why this is happening? BTW, I copied and pasted those dates in from Excel. Thanks for your help. Exel supports 2 date systems - 1900 & 1904. The system is imposed on a per-file basis, so it sounds like you're copying from a file that uses one system & pasting to a fi...

Countif Question 06-04-10
-- John ...

Calendaring Question
Hi, Is there a way to limit the number of recipients who can accept a calendar invitation? For example, if I sent an invite to 100 people but was able to accommodate only the first 30 recipients, the invite would deny anyone after the first 30 to respond. I would be happy to entertain ways of doing this in either Outlook or Exchange, I just can't think of anything. Thanks, Dan I don't believe there's any way to do that...unless there's some type of 3rd party solution...not wanting to be too obvious, though, if you can only accommodate 30, best to just invite 30 people,...

Newbie question on Admin vs Developer vs Power User
I'm learning Sharepoing/Moss now and there seems to be a definite distinction in all the course materials between Administrators/Developers/Power Users They seem to make a big point about identifying 'power users' in different sections of the work environment to handle a lot of the stuff, but then again, all the tasks seem to blur from one role to the other - and, if you gave enough of the tasks over to the 'Power users', as they call them, it seems to take away from the other roles. Now, maybe I've never worked in a business enterprise that's big enoug...

Public folders calendar question
We use the global calendar quite frequently and now have begun to set up department public calendars. We want those deparment calendars to update the global calendar is this possible or are there better solutions. We are running SBS 2003 Premium (Exchange 03, outlook 03) Thanks ...

Newbie Question #2
I just created a spreadsheet. Before adding data, I highlighted columns c,e,f,h etc (one at a time) and clicked on the $ to make these columns display as currency. I then entered quite a bit of data. While entering the data, it appeared as currency. After entering all of the data, I began trying to sum a column. At this point in time, the data seems to have lost its currency format, e.g., where two dollars and twenty-seven cents formerly appeared as $2.27 it now appeared as 2.27 and it was left justified. All efforts to highlight the column, or even to work with a single cell, and...

Circular logging question #2
If I create a new store with circular logging enabled, do I still need to restart the information store service? Thank you. Circular logging is activated at the Storage Group level. The GUI will prompt you to take all DBs offline and then online. Circular should never be used on back end servers. /Simon "justsimplequestions" <sigmatechnology@googlemail.com> wrote in message news:1173981863.481309.98010@o5g2000hsb.googlegroups.com... > If I create a new store with circular logging enabled, do I still need > to restart the information store service? > > Thank yo...

table design question
I have table of 40 milion rows (sql 2005). There is one column, Id, which is integer (basically month), and there are 20 different values for this column (around 2 million rows per id value). At the same time, there is very long primary key on this table (12 columns, around 400 bytes), and nonclustered index on this primary key. Table is being accessed frequently by Id, so I created clustered index on this column (usually, developers create temporary tables per id, and then do further processing) to lower physical reads... Does this sound like a desirable design? I don't wan...

XmlTextReader Question
I have the following XML i do the following to extract the name information XmlTextReader Reader = new XmlTextReader("C:\\names.xml"); while(tempReader.Read() ) { if(tempReader.Name.ToLower() == "name ") { //My problem here how to get firstname and last for the current name node by other words get the childs information from parent node } } <family> <name gender="Male"> <firstname>Tom</firstname> <lastname>Smith</lastname> </name> <name gender="Female"&g...

SFO Question ...
Hi there! Quite often the Outlook menu buttons "New CRM Contact", "New CRM Task", New CRM Appointment" or some of them, do not function. Is this happening to any of you? I have noticed that, whenever this happens, when I go offline, the CRM cannot syncronise the corresponding items to the button that is inactive. For example when I cannot create a new CRM Contact from Outlook, I cannot import CRM Contacts by syncronization... Any help? Thanks a lot, Elena Hello Elena You have to reinstall the 4 mscrm forms for outlook. You can find them under Tools/Options/Advanc...

Table Question!
I have just noticed something about my 2 main tables tblOwnerInfo,Uses Auto Number as a form of ID tblHorseID, has No Auto Number Should I do anything about it.............Thanks Bob What version of Access, 2007 SR1 fixes autonumber problems. "Bob V" <rjvance@ihug.co.nz> wrote in message news:%23CJSSjPQIHA.4684@TK2MSFTNGP06.phx.gbl... >I have just noticed something about my 2 main tables > tblOwnerInfo,Uses Auto Number as a form of ID > tblHorseID, has No Auto Number > Should I do anything about it.............Thanks Bob > Disclaimer At least that is ...

file size question
i have a workshbook that uses vlookups to a separate workbook. the file jumped from 29kb to 2,068kb. is that normal? or are there things i can do to bring that file size back down? Hi James, I had the same with one of my files. It appeared that i had applied formatting and formulas to whole colums and rows, that seems to take a lot of memory. So i tried to apply the formatting and formulas to only the cells for which it was neccesary. That worked for my files. HTH Fred "James" <james@guidant.com> schreef in bericht news:e$rWN2xTEHA.1284@TK2MSFTNGP10.phx.gbl... > i...

Newbie Time Question #3
Oh I agree.. But I also want to contribute -- ACangem ----------------------------------------------------------------------- ACangemi's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=858 View this thread: http://www.excelforum.com/showthread.php?threadid=26314 ...

Dumb Question(s)
This may sound crazy, but exchange 2003 is new to me. I created a new user account and the user does not show up in the Global Address List!!!! I have no idea how to get them in there. Also, after a failed migration from a 5.5 server that copied mailboxes and created new user accounts on my server, I am unable to delete the mailboxes. I cannot figure out how to do that. Rather than import my user list from the old NT 4.0 server, I thought I'd just concentrate on mailboxes since there was not that many special user settings to begin with. Is that a bad approach? I would have left i...

Input position of current Node in XmlTextReader
Hello, Perhaps it's obvious, but I don't find any property in XmlTextReader to obtain the position of the current node. I know that I can obtain the position of the node in the current line (LinePosition) and the line number, but I need to know the position relative to the whole document. Thanks :-) alessnet@gmail.com wrote: > Perhaps it's obvious, but I don't find any property in XmlTextReader > to obtain the position of the current node. > I know that I can obtain the position of the node in the current line > (LinePosition) and the line number, but I need to ...

XMLTextWriter and XMLTextReader
I am looking for a way to open an xmltextwriter to append to an existing document. Currently I rename the existing document, then I created new one and copy over all the existing documents nodes. I would rather avoid renaming the files. These files can become quite large so I need to avoid loading an xmldocument as well. Does anyone have a pointer for me to review? Thanks in advance. I think I am going to go with this concept http://www.tkachenko.com/blog/archives/000053.html, I think it will suit my needs just fine. "amdrit" <amdrit@hotmail.com> wrote in messa...

HOOK QUESTION !
Hi ! I'm trying to build a hook that would capture the key pressed .. and if a specific combination of keys are presed my app will open and it will recieve the selected text in the app that was running when the key combination wass pressed ... is that possible ? how ? I searched for an example for a few days .. but no luck .. can anyone help me ? Thanks ! > I'm trying to build a hook that would capture the key pressed .. and if > a specific combination of keys are presed my app will open and it will > recieve the selected text in the app that was running when the key > ...

Questions before deploying the crm 1.2 system
Hello! We have been reviewing the documentation before deploying the MS CRM 1.2. We have a couple of oquestions: 1. When we install the crm will the CRM installation upgrade or in any way modify the Active directory schema? 2. Why are the Exchange router installed? 3. How many users can you run on a single CRM server? (I know that it is dependent on the HW) an example would be nice! Regards Niclas Lundstrom, Product Manager ...

how to chart question
Hi. I have some data about failures. the log file is like this (but really much longer): app1 03/04/2006 08:51 app2 03/04/2006 09:42 app1 03/04/2006 18:33 app3 03/05/2006 00:14 app1 03/05/2006 00:21 app2 03/05/2006 01:52 app1 03/06/2006 02:51 app3 03/06/2006 08:54 I would like to create some charts but don't know how. ex: app 3/4 3/5 3/6 app1 x x x app2 x app3 x ========================================= can someone point me in the correct direction? I'm guessing I'll have to group the data somehow. I have lots of data, so I...

Respond to questions in Newsgroup in a reasonable amount of time.
I was told a Convergence 2006 that this had been addressed and that if questions were not addressed by users within 48 hours that Microsoft would respond. That does not appear to be happening. My question 'GPS Error 56' from 4/17 has not had any response. Also, the "Contact Us" link at the bottom of the page in broken. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this lin...