Peter et al, The method was actually written by David Dancy. It was part of some XML methods he shared with the 4D community a number of years ago. Sure miss his presence in the 4D Dev world.
Hope this helps. Tom // ---------------------------------------------------- // User name(OS): ddancy // Date and time: 30/7/10, 01:15:07 // ---------------------------------------------------- // Method: DOM_DisplayXML // Description // Format XML element names and values for display in Hierarchical List // // // History // ---------------------------------------------------- // 30/7/10-ddancy: Created // // Parameters // ---------------------------------------------------- C_TEXT($1;$Root_xml) C_LONGINT($2;$Level_l) $Root_xml:=$1 $Level_l:=$2 C_TEXT($Element_xml;$Child_xml) $Element_xml:=$Root_xml C_TEXT($ElementName_t) C_TEXT($ElementValue_t) C_TEXT($AttrList_t) Repeat DOM GET XML ELEMENT NAME($Element_xml;$ElementName_t) DOM GET XML ELEMENT VALUE($Element_xml;$ElementValue_t) $AttrList_t:="" C_LONGINT($Attr_l;$AttrCount_l) $AttrCount_l:=DOM Count XML attributes($Element_xml) C_TEXT($AttrName_t;$AttrValue_t) For ($Attr_l;1;$AttrCount_l) DOM GET XML ATTRIBUTE BY INDEX($Element_xml;$Attr_l;$AttrName_t;$AttrValue_t) $AttrList_t:=$AttrList_t+" "+$AttrName_t+"="+"\""+$AttrValue_t+"\"" End for APPEND TO ARRAY(DOM_Reference_at;$Element_xml) APPEND TO ARRAY(DOM_ElementName_at;($Level_l*" ")+"<"+$ElementName_t+$AttrList_t+">") APPEND TO ARRAY(DOM_ElementValue_at;$ElementValue_t) $Child_xml:=DOM Get first child XML element($Element_xml) If ((OK=1)) DOM_DisplayXML ($Child_xml;$Level_l+1) End if $Element_xml:=DOM Get next sibling XML element($Element_xml) Until ((OK=0)) OK:=1 Tom From: Peter Mew [mailto:[email protected]] Sent: Tuesday, March 27, 2018 2:09 PM To: Benedict, Tom Cc: [email protected] Subject: Re: xml to array Hi Tom I would very much like to see your method thanks -pm On Tue, Mar 27, 2018 at 10:04 PM, Benedict, Tom <[email protected]<mailto:[email protected]>> wrote: Hi Peter, > >Is there a 4D command that will take a block of xml, and turn it into a number >of arrays (or pairs of arrays (attribute and value) Or is this a stupid >question Thanks –pm I have a method to do this. Let me know if you need it. Tom Benedict Optum Inc This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

