Parsing XML #2

Hi,

I am parsing a XML string (see code below) by loading into XMLDocument and 
selecting certain node (Result) and loop through it.   Instead of using 
item(), is there a way to get the element value by name?

Also, is there a way to using the XmlTextReader to move to Search/Result and 
then loop though each node?


XmlDocument doc = new XmlDocument();

doc.Load(new System.IO.StringReader(xmlResponse));

XmlNodeList nodeList = doc.SelectNodes("Search/Result");

foreach (XmlNode node in nodeList)

{

string dbID = node.ChildNodes.Item(0).InnerText;

....



Thanks


0
george
9/10/2006 11:08:56 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
487 Views

Similar Articles

[PageSpeed] 44

FxCop will flag any usage of XmlNode or XmlElement & recommend using 
IXPathNavigable instead.  Using that, you should use 
IXPathNavigable.Select(String xpathExpression), which will allow for 
query-by-name.



0
9/10/2006 11:52:10 PM
How do you handle many nodes (see below)?  That is my I am using 
XMLDocument.

  <Results>
    <Result>
      ...
    </Result>
    <Result>
      ...
    </Result>
    <Result>
      ...
    </Result>
  </Results>


"Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in message 
news:ebsZhQT1GHA.1288@TK2MSFTNGP03.phx.gbl...
> FxCop will flag any usage of XmlNode or XmlElement & recommend using 
> IXPathNavigable instead.  Using that, you should use 
> IXPathNavigable.Select(String xpathExpression), which will allow for 
> query-by-name.
>
>
> 


0
george
9/11/2006 12:22:00 AM
I figured it out.

string dbID = node["ID"].InnerText;


"george" <g@g.com> wrote in message 
news:u6R1sgT1GHA.4976@TK2MSFTNGP02.phx.gbl...
> How do you handle many nodes (see below)?  That is my I am using 
> XMLDocument.
>
>  <Results>
>    <Result>
>      ...
>    </Result>
>    <Result>
>      ...
>    </Result>
>    <Result>
>      ...
>    </Result>
>  </Results>
>
>
> "Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in 
> message news:ebsZhQT1GHA.1288@TK2MSFTNGP03.phx.gbl...
>> FxCop will flag any usage of XmlNode or XmlElement & recommend using 
>> IXPathNavigable instead.  Using that, you should use 
>> IXPathNavigable.Select(String xpathExpression), which will allow for 
>> query-by-name.
>>
>>
>>
>
> 


0
george
9/11/2006 12:53:50 AM
Reply:

Similar Artilces:

Ordering xml using xsl in c#
Hi, I have a xml dataset I'd like to order, and save in that order. I've written an xsl to do the transformation, but because the xml file has a xsd namespace, it doesn't work. A cutdown version of the xml file looks like this: <?xml version="1.0" standalone="yes"?> <hsPrinters xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xmlns="http://tempuri.org/printer.xsd"> <city> <code>LN</code> <name>London</name> <comment>Herbert Smith London Offices</comment> </ci...

upgrade to 2.0.0114 from 1.31010
Hi group, I plan to peform this upgrade in 10 days from now... just before the Holidays shopping season! HQ with 7 stores Any general words of advice, suggestions of steps to be taken that is not found in the published MS documentation. Thanks Frederic Hurlet Did it for 5 stores a few weeks ago and it is all pretty straightforward Only thing I will say to make sure is that if you have purchased any add-ons for RMS make sure you find out if you need to upgrade those too, most of them have to be "Frederic Hurlet" wrote: > Hi group, > > I plan to peform this upgrade...

Parsing Question
I've done parsing where you have one delimiter such as a comma or space. What if you have more than one? Example data: sStr(0) = "3/9" sStr(1) = "3/11 3/15-" sStr(2) = "3/8+ 3/12" sStr(3) = "3/9 3/15" sStr(4) = "3/8- 3/10+ 3/15" The strings above are Month/Day with some having an additional - or + character next to it. These dates are extracted from Excel cells as strings. I need to break those strings down into individual dates. So for sStr(4), I need to parse out "3/8", "3/10" and "3/15&...

how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible?
how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible? "Daniel" <softwareengineer98037@yahoo.com> wrote in message news:%23g11DbDOGHA.2176@TK2MSFTNGP10.phx.gbl... > how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it > possible? No -- the xml declaration is not represented in the XML Infoset. Cheers, Dimitre Novatchev ...

Export/import stock price from/to Money #2
I used Money 2003 in Taiwan (not USA). The stock is not USA stock, so I don't use the on-line update stock price. Is there any method to export/import my stock price ? Even write a program to do that, it's OK for me. Thanks. ...

serialization question #2
Hello, I have such question. I want to create SDI application to work with matix. I have a data that stored in the file in the form of the matrix: 1 2 3 4 5 6 7 8 9 0 1 2 or something like this one. The nambers of colonms and rows may vary. How can I read this file (serialize) and store each number in CArray for example? Thank you very much in advance Igor igor tarasov wrote: > Hello, > I have such question. I want to create SDI application to work with matix. I > have a data that stored in the file in the form of the matrix: > 1 2 3 4 > 5 6 7 8 > 9 0 1 2 > or someth...

excel to access #2
`hi all, i was wondering about having a userform from excel with its data feeding into an access table. Is that possible? I expect the answer is yes but...... at present my userform enters simply into a spreadsheet behind it i.e textbox1 = a1 etc. I have unfortunately cant attach my current workbook but if you email at steve.c.horton@gmail.com i will send it to you and if anyone can tell me how this can be done i would be most appreciative I have specified the current code below aswell if that helps. I have really only used access back in my uni days so i need some help here! If anyone c...

Ink #2
Sorry guys. The spam stuff was not my intent. I do oppoligies and won't happen again. I have never been on newsgroups before and not sure how to work them. I hope you guys can forgive a bad choice. Murphey ...

Locating xmlns nodes in XML documents (for XML document metrics)
I've been writing an XML document analyzer that reads XML document and tracks the metrics of the document. Statistics such as a node count fo each type of XML node are printed out I am trying to locate 'xmlns' nodes using the XPath (not DOM or SAX) API Unfortunately the XPathNavigator concept of namespace nodes for eac element is only accessible via MoveToFirstNamespace() an MoveToNextNamespace(). The XPath model constructs a namespace node lis for EACH ELEMENT where each namespace node represents a namespace CURRENTL IN SCOPE for the current XML node I would like to easily loca...

Signatures and MS Updates #2
We have a customer who says when ever windows updates they have to re-apply the signature in a new message in outlook 2003. Has anyone ever come across this? We also have a customer who reports that the same thing is happening, and has happened for the last 2 runs of windows updates. They are just using MS Office Pro 2003, no Exchange. Signature just get's turned to "none" and they have to re-enable it again. Does not happen to every pc at the office, only a couple of them. Any help and suggestions would be great Thanks Darin "David" wrote: > We have a c...

Parsing cells
Hi Folks, I have data in cells which is OCR`d from my phone bill, and some of the info is corrupt. Where I should be getting eg. 17 Nov 14:49 for date/time I am getting O17 Nov 14:49 or C17Nov 14:49. The reason is that there are unreadable icon characters to signify day or night. Questions: 1)How do I remove the faulty characters......they are always the first digit in the date if they are there. 2)How can I seperate the date and time into two adjasent colums of cells rather than their current format in one cell. Any and all help greatly appreciated. John Hi John You ca...

Unable to send e-mails #2
As soon as I hit "send & receive", I get a message from the System Administrator saying my e-mail is "undileverable" with the following text: Your message did not reach some or all of the intended recipients. Subject: RE: Mid-Atlantic Weekly Report 10/8 Sent: 10/10/2004 7:26 AM The following recipient(s) could not be reached: 'Scott Frigaard' on 10/10/2004 7:26 AM 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1) 'Andy Aweida' on 10/10/2004 7:26 AM 553 sorry, that domain isn...

What is the quickest way to get an xml based dataset to add entries to SQL Server?
Because there is no 'datareader' involved, what is the most efficient way to get an XML based dataset to be added to an SQL server dataset? I would hate to have to create a new SQL connection and iterate through making "executenonquery" for each row in the dataset. That seems horribly in-efficient. I know of no other way to get an xml based dataset to push data to the database though. Any pointers? Thanks for any pointers, Peter Robbins Freelance Programmer C#/PHP "MurdockSE" <murdock@nc.rr.com> wrote in message news:1153922058.675709.165630@h48g2000cwc.go...

Inport/Eport XML
I am running Microsoft Office 2000 on my work computers. I am editing a database and I need said database to export a table named Data Table to a .xml file. I also need to be able to import a .xml file and have it added to the same table. I don't know if 2000 has the capability. Check your VBA references for an XML library. I am using 2003 and we have it. You use the xmlExport and xmlImport methods to do that. -- Dave Hargis, Microsoft Access MVP "Bobby.Dannels@gmail.com" wrote: > I am running Microsoft Office 2000 on my work computers. I am editing > a database a...

blank email #2
I've been receiving a lot of email wirh blank subject and no body text. I was wondering how I could set up a rule to delete these emails. Im using Outlook 2002 I have the same problem, but with 2003. Because I never received them before, I'm thinking there is a problem with Outlook 2003. I'm getting about 2 a day. Also, there doesn't appear to be a rule that works with these "blanks." -- Dana Win XP & Office 2003 "Joe Blow" <anonymous@discussions.microsoft.com> wrote in message news:0a3701c4ad5c$3928ace0$a501280a@phx.gbl... > I&#...

sorting by number #2
I have a long list like this it is sorted in the first column A to Z but I want to sort by second column 1 , 2, 3, 4 etc. Help please -- XP home , Office 97 any or all responses are gratefully accepted and thank you for your time sorry forgot the list ANTHONY Merv, Ruth, Sarah, Jaremy 113 A.P.S. SERVICES 516 APOLLO DRILLING 63 APOLLO GOLD CORP 605 ARDIANNA ENTERPRISE 160 ARLA INVESTMENT 38 ARMSTRONG, Pat 10 ARPIN, Isabelle 495 ARPIN, Laurent, Carol, Valerie 458 ARSENAULT CLAIRE 22 ARSENAULT, Jean, Carol, Serge, Zoé 352 -- XP home , Office 97 any or all responses are gratefully acce...

payroll negative amount #2
I overpaid an employee. How do I run a negative amount in the payroll transaction entry? I get the message saying pay code cannot have a negative amount. Somehow I need to get this money adjusted. You will have to enter a one-time deduction. HS "alice" <anonymous@discussions.microsoft.com> wrote in message news:2d7801c507b2$79cdc9f0$a601280a@phx.gbl... >I overpaid an employee. How do I run a negative amount > in the payroll transaction entry? I get the message saying > pay code cannot have a negative amount. Somehow I need > to get this money adjusted. ...

test #2
...

Parse Nested Elements to Single DataGrid
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows don't have child rows in every relation - but trying to get all the child tables to go with the correct parent row programmatically is killin...

Text to Columns #2
Having used the "Text to Columns" tool once on a worksheet (to separate by spaces), I find I can't switch it off. Every subsequent time I try to copy and paste some other text from a single cell, for some completely different reason, the pasted data gets spread over many columns if there are any spaces in the text. How can I switch off "Text to Columns" after using it? This surely must be a bug, it's so unreasonable! Tod Excel likes to help by remembering your last settings. This can be really handy if you're pasting similar stuff lots of times. You ...

How to add custom toolbar(with edit box and Spin controlls) in my application #2
hi frnds i have to add a toolbar in my application and toolbar should have two edit box with spin controls and 4 buttons and i have to add it in my existing application. so plz help me, how to do it plz reply with code n suggestion ur frnd Premanshu sInha ...

Consolidation #2
I have a large amount of data in several columns that I would like to put into one in the following manner: A1=x B1=y C1=z I want to consolidate x y and z with commas in one cell = x,y,z Thanks for the help! -- capnsean ------------------------------------------------------------------------ capnsean's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=25049 View this thread: http://www.excelforum.com/showthread.php?threadid=385725 I guess spacing doesn't work, and I won't want to tempt fate in trying html. What I mean is this: A1=x B1=y C1=z I wan...

xml graphic representation
I'm new to using XML, so I'm seeking some general pointers about approaching a project. I'd like to read the sitemap xml file, and generate a graphic representation of the website from the site map. I would like to do this dynamically (creating the page from the current sitemap file). I'm wondering if there are some built in functions I can use, for example to: 1) parse the xml file, creating units at each node 2) interpret levels within the file 3) create graphics based on each node, writing the node property in the text of the graphic object. I know what functions I'...

Reconcile #2
I am attempting a Reconcile of the Sales to the GL, I have found invoices in the subledger which are not in the GL for that particular period. Where can I look to determine why this could have happenned? Inquiry into SOP Doc then drill into date expansion field. Looking for GL Posting Date. Also may looking at Posting Setup (Post by transaction date or Batch Date). For more help about reconciling in Dynamics GP, Check out The Closer. www.reporting-central.com "rcr" wrote: > I am attempting a Reconcile of the Sales to the GL, I have found invoices in > the subledger wh...

generate xml ...
hi, i need to generate an xml files of some data in my database ... i've an xml sample of the result xml nad i've to create a xml with the same structure ... which it is the better and faster way? Can i retrieve a schema from the sample.xml and then write an xml based on this schema ? Might i use Dataset.readxmlschema , Dataset.readxml and Dataset.writexmlschema , Dataset.writexml ??? tnx in advance andrew ...