Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7,C#
Expertise: Intermediate
Oct 19, 2002

Handle child XML nodes with care

When you work with XML documents loaded into an XmlDocument class, you often need to examine the contents of child nodes. The XMLDOM programming interface purposedly provides the ChildNodes property. In the .NET XmlDocument class, ChildNodes returns an internal object of type XmlChildNodes. (The object is not documented, but you can easily verify this claim by simply checking the type of the object that ChildNodes returns.)

XmlChildNodes is not a true collection. It is implemented as a linked list and does not cache any information. What does this mean to you?

For example, when you access the Count property to know how many children a given node has, the object returned by ChildNodes scrolls the entire list to count the number of nodes on the fly. When you ask for a particular node through the Item property, the list is scanned from the beginning until a matching node is found.

Scrolling forward through the list of child nodes is fast and effective. The same can

Dino Esposito
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date