Differences between xmlelement and xmlnode

Source: Internet
Author: User

Xmlelement is a subclass of xmlnode (and so is xmlattribute, xmltext, xmldocument, etc .). there is no performance implication of using one over the other at all, since xmlnode is simply the base class for all types of nodes in a dom xml document instance.

It just so happens, that pointer of the APIs in the DOM return an xmlnode reference because they cocould return several kinds of nodes. for example, with selectsinglenode (), your XPath expression cocould return an element, an attribute, an xmltext and what not; whether you handle it as an xmlnode or cast it to the right type is just a matter of how you write your code but won't affect performance at all.

Xmlelements are a type of node. in fact, if you look at the members of xmlnode and xmlelement in. 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 types of nodes you find.

Element is a subset of nodes. xmlnode represents a node, including xmlelement and xmlattribute. For example:

< Alarm lock = "true" > // Node
< Time > // Node
Stringvalue // Node
</ Time > // Node
</ Alarm > // Node

the above alarm (element node), lock (attribute node), time (element node), and stringvalue (text node) are all nodes, but only ...... and stringvalue are elements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.