automatically create fields from xml tree

Chipp Walters chipp at
Wed Jan 5 18:28:35 EST 2005


It depends on what your XML structure looks like: For instance if your 
XML looks like:

<field>Address 1</field>
<field>Address 2</field>

Then have the script of a btn

on mouseUp
   put URL("file:text.xml") into tXML
   repeat for each line L in tXML
     put getTag(L) into tTagName
     switch tTagName
     case "field"
       create field getTagData(L,"field")
     case "button"
       create button getTagData(L,"button")
     end switch
   end repeat
end mouseUp

function getTagData pTagData,pTagName
   filter pTagData with "<" & pTagName & ">*"
   replace "<" & pTagName & ">" with "" in pTagData
   replace "</" & pTagName & ">" with "" in pTagData
   return pTagData
end getTagData

function getTag pStr
   put offset("<",pStr) into tStart
   put offset(">",pStr) into tEnd
   return char tStart+1 to tEnd-1 of pStr
end getTag

This will create a field for each field element and a button for each 
button element.

Hope that helps,


Bob Hartley wrote:
> Hi all.
> Is it possible to automatically create fields from an xml tree using the 
> runrev xml commands or do I need to know the names of the xml items?

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.7 - Release Date: 12/30/2004

More information about the Use-livecode mailing list