Delphi操作XML:TXMLNode类(一)

4.1.16.TxmlNode

  TXmlNode =
class(TPersistent)

  该TXmlNode代表在XML文件中的元素。每个TNativeXml拥有一个根(Root)元素。在根元素下面,子元素可以嵌套(没有限制有多深)。ElementType属性定义这个节点是什么类型的元素。

4.1.16.1.AttributeByName

  property AttributeByName
[const AName: UTF8String]: UTF8String;

  AttributeByName返回的指定属性名称AName的属性的值。设置AttributeByName可以添加这个属性到属性列表,或取代现有的属性。

4.1.16.2.AttributeByNameWide

  property
AttributeByNameWide [const AName: UTF8String]: UnicodeString;

  AttributeByName返回的指定属性名称AName的属性的UnicodeString类型值。设置AttributeByName可以添加这个属性到属性列表,或取代现有的属性。

4.1.16.3.AttributeCount

  property AttributeCount:
integer;

  返回当前节点的属性数量。

4.1.16.4.AttributeName

  property AttributeName
[Index: integer]: UTF8String;

  根据索引(Index)读属性的名字。注意,属性索引是从0开始的,索引(Index)值从0AttributeCount – 1

4.1.16.5.AttributePair

  property AttributePair
[Index: integer]: UTF8String;

  根据索引(Index)读属性的名字与值,这个返回的UTF8String字符串中的名字(Name)与值(Value)TAB符号(#9)分割。

  注:实际上是用等号(=)分割的。这个值中的转义字符(escape)没有转换。

4.1.16.6.AttributeValue

  property AttributeValue
[Index: integer]: UTF8String;

  根据索引(Index)读这个属性,返回UTF8String类型的属性值;写这个属性,则设置UTF8String类型的属性值。

4.1.16.7.AttributeValueAsInteger

  property
AttributeValueAsInteger [Index: integer]: integer;

  根据索引(Index)读这个属性,返回Integer类型的属性值,如果这个值不能转换,返回0;写这个属性,则设置Integer类型的属性值。

4.1.16.8.AttributeValueAsUnicodeString

  property
AttributeValueAsUnicodeString [Index: integer]: UnicodeString;

  根据索引(Index)读这个属性,返回UnicodeString类型的属性值;写这个属性,则设置UnicodeString类型的属性值。

4.1.16.9.AttributeValueDirect

  property
AttributeValueDirect [Index: integer]: UTF8String;

  设置或获取这个原始属性值,可以回避转义字符转换(escape)函数。你不能在这个值中设置&和引用(quote)Ansi字符,或者XML不支持的字符。

  注:这个值中的转义(escape)字符不会被转换。

4.1.16.10.BinaryEncoding

  property BinaryEncoding:
TBinaryEncodingType;

  BinaryEncoding 属性值用于返回或设置父文档(Parent Document)BinaryEncoding 属性值。

4.1.16.11.BinaryString

  property BinaryString:
RawByteString;

  使用BinaryString可以读写Base64编码格式的节点值。如果是标准的文本信息,不使用这个方法,而是ValueAsString

4.1.16.12.CascadedName

  property CascadedName:
UTF8String;

  这个属性返回当前节点的名字及索引,并级联递归上层节点到根节点。各节点信息利用下划线(_)分割。

  注:很奇怪,根节点竟然有一个父节点,而且那个节点没有写入文件。这个属性会返回那个奇怪节点的索引0

4.1.16.13.Document

  property Document:
TNativeXml;

  这是一个指向NativeXml格式文档的指针,它也许指向空(Nil)

4.1.16.14.ElementType

  property ElementType:
TXmlElementType;

  ElementType用于描述节点的元素类型。

4.1.16.15.FullPath

  property FullPath:
UTF8String;

  Fullpath 返回从根节点(Root)到当前节点的完整路径,例如:
/Root/SubNode1/SubNode2/ThisNode

4.1.16.16.Name

  property Name: UTF8String;

  Name属性用于读写节点的名字。这个完整的名字也许包括命名空间。(Namespace:Name)

4.1.16.17.NodeCount

  property NodeCount:
integer;

  NodeCount 是这个节点的子节点数。可以利用它遍历子节点,例如:

with MyNode do

  for i := 0 to NodeCount - 1 do

    with Nodes[i] do

    ..processing here

4.1.16.18.Nodes

  property Nodes [Index:
integer]: TXmlNode;

  使用Nodes可以连接到当前XML节点中以Index指定的子节点。注意这个列表从0开始,Index有效值从0NodeCount – 1

4.1.16.19.Parent

  property Parent: TXmlNode;

  Parent 指向当前XML节点的父节点。

4.1.16.20.Tag

  property Tag: integer;

  Tag是一个Integer类型值,开发者可以随意使用它。 Tag 不保存到XML中。 Tag 常常用于表明一个GUI 元素

4.1.16.21.TotalNodeCount

  property TotalNodeCount:
integer;

  TotalNodeCount 用于表示子节点总数,包括子节点的子节点。使用它返回XML 文档的节点总数:

  Total := MyDoc.RootNodes.TotalNodeCount;


4.1.16.22.TreeDepth

  property TreeDepth:
integer;

  读 TreeDepth属性可以得到当前XML 节点的嵌套层次。根节点(Root)TreeDepth属性为0

4.1.16.23.ValueAsBool

  property ValueAsBool:
boolean;

  读取ValueAsBool 属性,可以返回布尔(boolean)类型的节点值,如果无法转换,引发一个异常。设置 ValueAsBool 将转换布尔类型为UTF8String类型并写入到节点值中。参照ValueAsBoolDef函数。

4.1.16.24.ValueAsDateTime

  property ValueAsDateTime:
TDateTime;

  ValueAsDateTime 返回日期时间 (TDateTime) 类型的节点值,如果无法转换,引发一个异常。设置ValueAsDateTime 将转换TDateTime类型为UTF8String类型并写入到节点值中。参照 ValueAsDateTimeDef函数。

4.1.16.25.ValueAsFloat

  property ValueAsFloat:
double;

  ValueAsFloat返回浮点(float) 类型的节点值,如果无法转换,引发一个异常。 设置ValueAsFloat将转换float类型为UTF8String类型并写入到节点值中。参照 ValueAsFloatDef函数。

4.1.16.26.ValueAsInt64

  property ValueAsInt64:
int64;

  ValueAsIn64返回64位整数(int64) 类型的节点值,如果无法转换,引发一个异常。 设置ValueAsIn64将转换int64类型为UTF8String类型并写入到节点值中。参照 ValueAsInt64Def函数。

4.1.16.27.ValueAsInteger

  property ValueAsInteger:
integer;

  ValueAsInteger返回整型(integer) 类型的节点值,如果无法转换,引发一个异常。 设置ValueAsInteger将转换integer类型为UTF8String类型并写入到节点值中。参照 ValueAsIntegerDef函数。

4.1.16.28.ValueAsString

  property ValueAsString:
UTF8String;

  ValueAsString 返回没有转义字符(escape)版本的ValueDirect ValueDirect中所有的转义字符都必须被编码转换(例如"&" 转换为"&")ValueAsString总是解码返回原始格式,使用ValueAsString设置节点的文本值,所有转义字符被编码转换。

4.1.16.29.ValueAsUnicodeString

  property
ValueAsUnicodeString: UnicodeString;

  ValueAsUnicodeString 返回UnicodeString格式的没有转义字符(escape)版本的ValueDirect。设置这个节点的文本值,需要将所有转义字符编码转换。
原文地址:https://www.cnblogs.com/acuier/p/2352255.html