• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Delphi操作XML:TXMLNode类(一)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
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;

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Delphi之第七课字符串操作发布时间:2022-07-18
下一篇:
IE-“无法浏览网页” 教你十招解决疑难杂症 - 疯狂delphi发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap