Some common signals with OmniXML:
Loading a document from a file or from a stream or line
xml := CreateXMLDoc xml.Load(FileName); xml.LoadFromStream(XMLAsStream); xml.LoadXML(XMLAsString)
Select one node (fifth child):
MyNode := XML.ChildNodes.Item[4]; MyNode := XML.SelectSingleNode('Node[5]');
XPath selection
MyNode := XML.SelectSingleNode('/MyNodes/SpecificNodes/Node[5]');
Select a collection of nodes
MyNodes := XML.SelectNodes('/MyNodes/SpecificNodes/Node');
If you downloaded from http://www.omnixml.com/download.html , then there is a directory called demo inside that contains all the demos. They will explain to you almost everything.
If you decide to use SimpleStorage on top of OmniXML, let me show you what your top example will look like using SimpleStorage.
xml := StorageFromFile(rssFileName) for channel in xml.Elements('channel') do begin ListBox1.Items.Add('['+channel.Get('title')AsStringDef+']') for Item in channel.Elements('item') do ListBox1.Items.Add(' <'+ Item .Get('title')AsStringDef+'>') end; //for iChannel
No, you see how much template code was missing (21 lines of code were reduced to 7 for the same functionality). There is no need to check if node exists, etc., and the enums help a lot. I highly recommend you use this approach because it is much clearer.
source share