On 5 Aug 2014, at 15:00, j...@souslelogo.com wrote: > Hi list > > When I have a tree such as the following one : > <person> > <aliases> > <name>name1</name> > <name>name2</name> > <name>name3</name> > </aliases> > </person> > > Is there a simple way to loop through the children of <aliases> > and get their respective contents ? > Please correct me is I'm wrong, but it looks like all xml functions > require the path to the child, which doesn't work in this case for > the path person/aliases/name always leads to the first child... > > I found a workaround by sucessively deleting the 1st child and > then getting the firstchildcontent, but that means more lines of > code and destruction of parts of the tree...
There may be a better way, but using revXMLChildNames allows you get the child names with the index appended (e.g. name[1], name[2], etc.) put field 1 into tData //source of xml text put revXMLCreateTree(tData,true,true,false) into tID put revXMLChildNames(tID, "person/aliases/", cr, "name" ,true) into tNameNodes put "" into tOut repeat for each line tNodeName in tNameNodes put "person/aliases/" & tNodeName into tNode put revXMLNodeContents(tID, tNode) & cr after tOut end repeat put tOut into field 2 Cheers Dave Cragg _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode