automatically create fields from xml tree

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


Bob,

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

<field>Name</field>
<field>Address 1</field>
<field>Address 2</field>
<field>City</field>
<field>State</field>
<button>Cancel</button>

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")
       break
     case "button"
       create button getTagData(L,"button")
       break
     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,

Chipp


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