I have a big XML file, around 50 megs and I trying to use the OmniXML library to manipulate the XML document.
I didn't understand the demos in OmniXML...
The XML file have a structure like this:
<rollercoaster build="0.1 (Dec 30 2010)" debug="no">
<settings name="roller coaster" sourcefile="rolcost.pas">
<description>Roller Coaster admin function</description>
<year>2010</year>
<manufacturer>ArtTeck</manufacturer>
<sears name="sears.uk" size="1024" mda="87117ba5082cd7a615b4ec7c02dd819" region="england" set1="25d"/>
<sears name="sears.dk" size="1056" mda="326dbbf94c6fa2e96613dedb53702f8" region="denmark" set1="25d"/>
<sears name="sears.gr" size="6802" mda="01b4c38108d9dc4e48da4f8d5821377" region="greece" set1="65d"/>
</settings>
<settings name="roller coaster2" sourcefile="rolcost2.pas">
<description>Roller Coaster user function</description>
<year>2010</year>
<manufacturer>ArtTeck</manufacturer>
</settings>...... and goes on
</rollercoaster>
The things I want to know are:
uses
OmniXML,
OmniXMLUtils;
procedure TForm28.FormCreate(Sender: TObject);
var
descNode: IXMLNode;
iNode : integer;
node : IXMLNode;
nodeList: IXMLNodeList;
xml : IXMLDocument;
begin
xml := CreateXMLDoc;
if XMLLoadFromFile(xml, 'c:\0\roller.xml') then begin
// node enumeration in D2005+
//for node in XMLEnumNodes(xml, '/rollercoaster/settings') do
// lbLog.Items.Add(GetNodeTextStr(node, 'description'));
// node enumeration in D7 and older
nodeList := xml.SelectNodes('/rollercoaster/settings');
for iNode := 0 to nodeList.Length - 1 do begin
node := nodeList.Item[iNode];
lbLog.Items.Add(GetNodeTextStr(node, 'description'));
end;
// selecting a single node with specified attribute name
node := xml.SelectSingleNode('/rollercoaster/settings[@name="roller coaster2"]');
// accessing subnode text
lbLog.Items.Add(GetNodeTextStr(node, 'description'));
// accessing subnode text, alternative way
descNode := node.SelectSingleNode('description');
lbLog.Items.Add(GetNodeText(descNode));
// accessing node attribute
lbLog.Items.Add(GetNodeAttrStr(node, 'sourcefile'));
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With