X系列一 XAttribute class

意图

本文将解释 XAttribute 类。这个类在xml 元素(element)中构建属性(attribute)。通过本文你能了解到它的用法。

什么事xml中的属性?

xml属性是一个和xml元素有关的名值对(Name/Value)。XAttribute 类代表一个xml属性。

XAttribute 类

XAttribute 类在System.Xml.Linq命名空间 ,它继承XObject。

using System;
using System.Collections.Generic;
using System.Xml;
 
namespace System.Xml.Linq
{
    public class XAttribute : XObject
    {
        public XAttribute(XAttribute other);

        publicXAttribute(XAttribute other ,object other );
        ...

    }
}

需要注意的五个方面

  • XElement 包含一系列attribute。
  • Attributes 必须有一个唯一的名字对于指定的element。
  • Attributes 不是节点(node)。
  • Attributes 在xml tree中被维护。
  • 当attributes 从element中返回,它们不是有序的。

 

 

posted @ 2012-03-06 14:54  UnhandleException  阅读(358)  评论(0)    收藏  举报