469,924 Members | 1,429 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

Best Practice: Loop through Nodes in NodeList vs. XPathNodeIterator

Hi,

say I have an xml file with an X number of nodes I want to loop through (to,
for example, display each node as a HyperLink in an asp.net webpage). Which
of both is best practice:

1. Loop through a NodeList (e.g.: foreach XmlNode in XmlNodeList ... )
2. or use an XPathNodeIterator

Are there any differences in performance? Are both used for different
situations?

Thanks,
Vincent
Nov 11 '05 #1
1 8223
panik wrote:
say I have an xml file with an X number of nodes I want to loop through (to,
for example, display each node as a HyperLink in an asp.net webpage). Which
of both is best practice:

1. Loop through a NodeList (e.g.: foreach XmlNode in XmlNodeList ... )
2. or use an XPathNodeIterator


I assume you get XmlNodeList via SelectNodes() method. Then both approaches
are equivalent, becuase SelectNodes() is just a wrapper around
XPathNodeIterator, which provides list-like functionality.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by arvindsd | last post: by
4 posts views Thread by Larry R | last post: by
1 post views Thread by Sonu Kapoor | last post: by
1 post views Thread by Patrick F | last post: by
6 posts views Thread by Grant | last post: by
9 posts views Thread by Art | last post: by
2 posts views Thread by Thirsty Traveler | last post: by
14 posts views Thread by marfi95 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.