开发者

omni xml , is there a simple current example for reading xml file?

开发者 https://www.devze.com 2023-03-30 16:53 出处:网络
Looking for readable example use o开发者_开发百科f Omni Xml package. the documentation now is 2 examples, for loading and writing, nothing about reading, nor iterating.

Looking for readable example use o开发者_开发百科f Omni Xml package.

the documentation now is 2 examples, for loading and writing, nothing about reading, nor iterating.

could you provide a simple reading Xml ,example of one repeatable property

such as

<root>
<value p1=1></value>
<value p1=2 p2='32432'/>
<value p1=3 p3='fdsf'><other></other></value>
</root>

how to iterate over all the values and get the p1 property.


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;

Warning: Untested, written in browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消