寻找Omni Xml包的可读性使用示例。
现在的文档是两个示例,用于加载和写入,不涉及读取,也不涉及迭代。
你能提供一个简单的读取Xml,一个可重复属性的例子吗
比如
<root>
<value p1=1></value>
<value p1=2 p2='32432'/>
<value p1=3 p3='fdsf'><other></other></value>
</root>如何遍历所有值并获取p1属性。
发布于 2011-08-25 01:28:23
uses
OmniXML,
OmniXMLUtils;
var
node : IXMLNode;
other: IXMLNode;
xml : IXMLDocument;
begin
xml := CreateXMLDoc;
if XMLLoadFromFile(xml, 'fname.xml') then begin // 3 more notes
for node in XMLEnumNodes(xml,'/root/value') do begin
Writeln(GetNodeAttrStr(node, 'p1', ''), ';', GetNodeAttrStr(node, 'p2', ''), ';',
GetNodeAttrStr(node, 'p3', ''));
other := SelectNode(node, 'other');
end;
end;
end;警告:未经测试,在浏览器中编写。
https://stackoverflow.com/questions/7177800
复制相似问题