zoukankan      html  css  js  c++  java
  • XmlElement和XmlNode的区别

    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 many of the APIs in the DOM return an XmlNode reference because they could return several kinds of nodes. For example, with SelectSingleNode(), your XPath expression could 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 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. 

    Element是Node的子集,XmlNode表示一个节点,包括XmlElement(元素)和XmlAttribute(属性)等。 如:

    <Alarm lock="true">             //node  
          <Time>                       //node  
              StringValue              //node  
          </Time>                      //node  
    </Alarm>                           //node 


      以上Alarm(元素节点),lock(属性节点),Time(元素节点),StringValue(文本节点)都是Node,但是只有 <Alarm>......</Alarm>和<Time>StringValue</Time>是Element  

     来自 钢铁人生:http://www.cnblogs.com/engine1984/archive/2009/01/13/1288388.html

  • 相关阅读:
    【软工4】:软件工程和文档
    ER模型图工具:PowerDesigner
    【软工3】:软件工程视频知识总结
    【软工2】:软件开发阶段
    【软工1】:软件计划及软件需求
    【机房收费系统 5】:验收总结(思想)
    【机房收费系统 4】:VB获取标准北京时间,免除时间误差
    网络经济与企业管理(一)
    【机房收费系统 3】:文本框输入数字、小数点、退格键
    .NET Framework
  • 原文地址:https://www.cnblogs.com/dragonstreak_1/p/1742936.html
Copyright © 2011-2022 走看看