XmlNode and XmlElement: the same...but different

A co-worker was looking at some code I wrote some time ago showing how to create and XML document from scratch using the DOM. He asked for a succint definition of what distinguishes an XmlNode from an XmlElement. For me, it's one of those things I have just functionally done but never fully articulated like this, at least beyond, "Well, elements are a kind of node". So, I decided to put my brain on the matter and come to a crisper definition that I could on my blog. I put my newbie hat on and did some MSDN searches. I was not surprised to find that in general, we never deal with the question (I hope someone who knows better corrects me on this publicly) so directly. There is always this tacit assumption that people know the difference and merely want to get busy with the members of the objects. My co-worker looked diligently before asking me the question. So, for the record, here's a basic definition that I will amend as people post feedback.

It's true, elements are a type of node. In fact, if you look at the members of XmlNode and XmlElement in the .NET Framework, you will see that they are very much alike, but XmlElement has more going on. It inherits XmlNode and then is further customized. This is because an element is more specialized. A node is more general in scope. The document is a node, a processing instruction is a node, and so forth. Elements are different. If you look at the XmlNodeType property of an element, you will see that it is Element, one of the many types of nodes you find.

Getting the fundamentals down solid is important. Tomorrow, I return to my discussion of the vagaries of WordProcessingML.

Anyone messing with XML needs to read Signs on the Sand- Oleg Tkachenko's blog. It's compulsory reading.

Rock Thought for the day: I've mentioned this album before, I have had a few people ask me about it in the past week, so I feel compelled to discuss it again: Probot.

Dave Grohl deserves much more credit for being one of the true avatars in the music industry today. He has sweeping creative energy, is an excellent musician and song writer, and he understands how to exploit various genres without making it all seem so deliberate. Also, unlike so many in the business today, he pays true homage to his predecessors in a self-effacing way. How refreshing. He's just gotta-

Rock On