Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Handle child XML nodes with care
[ All Languages » VB.net »  XML]

Total Hit ( 2638)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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’t be said for backward scrolling. The list of nodes is not double-linked, and each node doesn’t also store a pointer to the previous one in the list. For this reason, the previous sibling is reached by walking through the list from the beginning to the node that precedes the current one.

To summarize, when you are processing XML subtrees, try to minimize calls to PreviousSibling, Item, and Count because they always walk through the entire collection of subnodes to get their expected output. Whenever possible, design your code to take advantage of forward-only movements and perform them using NextSibling.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.