Dumb XML library question
jbv at souslelogo.com
jbv at souslelogo.com
Tue Aug 5 10:51:27 EDT 2014
Thanks Dave,
I had noticed revXMLChildNames but I didn't know that
the child tag followed by a number inside brackets could
be used to form the path to a specific child...
jbv
>
> On 5 Aug 2014, at 15:00, jbv at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list