Save all xml nodes to db without looping through it

Posted by AndreMiranda on Stack Overflow See other posts from Stack Overflow or by AndreMiranda
Published on 2011-01-11T14:28:33Z Indexed on 2011/01/11 15:53 UTC
Read the original article Hit count: 380

Filed under:
|
|

I have this xml:

<Path>
  <Record>
     <ID>6534808</ID>
     <Distance>1.05553036073736</Distance>
  </Record>
  <Record>
     <ID>6542471</ID>
     <Distance>1.05553036073736</Distance>
  </Record>
  ... and about more 500 nodes
</Path>

And I'm using the code below to get all "Record" nodes:

XmlNodeList paths = xDoc.SelectNodes("//Record");

And, after that, I save each record to database. But, the problem is that I'm using a foreach to loop through this nodes and the count of this nodes may be more than 500, sometimes it gets up to 1000 "Records" node. And this gets too long...

Is there a way to save all of these nodes without looping through it?

Thanks!!

© Stack Overflow or respective owner

Related posts about Xml

Related posts about c#-3.0