Many, many thanks Tracy - I thought I had tried something along those lines without success but your suggestion fits the bill perfectly.
Paul Newton -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of Tracy Pearson Sent: 21 March 2016 16:54 To: [email protected] Subject: RE: Need help with parsing XML Paul Newton wrote on 2016-03-21: > Hi all > > I have the following simplified XML > > <Formats> > <Bank id="1" name="AIB"> > <Content text = "line1" value="value1"/> <Content text = "line2" > value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content > text = "line1" value="value1"/> <Content text = "line2" > value="value2"/> <Content text = "line3" value="value3"/> </Bank> > </Formats> > > With the following code I can iterate through the banks and display > their names as follows > > goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") > gcolElements = goxml.getElementsByTagName("Bank") For Each element In > gcolElements ? > element.attributes.item(0).text,element.attributes.item(1).text > EndFor > > But for each bank I need to iterate through the content entries for > that bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome > > Many thanks > > Paul Newton > Paul, There are multiple ways to parse the XML DomDocument. You grabbed all the elements called "Bank", you could then grab the elements called "Content" or loop through the child nodes. goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text IF element.haschildnodes FOR EACH content IN element.childNodes ? content.attributes.item(0).text, content.attributes.item(1).text NEXT ENDIF EndFor Tracy Pearson PowerChurch Software [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

