This approach takes about
11 ticks to do 20,000 lines of XML
and creates a single tab-delim table
--
but first fix the malformed tag
<age>12<age>
<age>12</age>
-----------------
on parseXML
put empty into MT
put tab into TB
put "^" into TB --remove after debugging
put fld incmgTxtFld into dataBlock
replace CR with MT in dataBlock --purge all
put "orphanage, small-child, name, age" into tree
replace space with MT in tree
replace (item 1 of tree) with CR in dataBlock
--isolate each small-child & trunc data line
replace ("</" & item 2 of tree & ">") with CR in dataBlock
--make sure each line a good data line
get ("</" & item 2 of tree & ">")
filter dataBlock with ("<" & item 2 of tree & space & "*")
--isolate data & build a table
repeat for each line LNN in dataBlock
put LNN into tblRow
repeat for each item ITM in (item 3 to -1 of tree)
replace "</" & ITM & ">" with MT in tblRow
replace "<" & ITM & ">" with TB in tblRow
end repeat
replace "=" with CR in tblRow
put line 2 of tblRow & CR after newDataTable
end repeat
replace ">" with MT in newDataTable
put newDataTable into msg
end parseXML
-----------------
LC chunking is very fast.
Hope this helps
Jim Ault
On Oct 17, 2011, at 12:45 AM, Sivakatirswami wrote:
I am an XML newbie:
if you want to extract data from a series of identical nodes in a
XML file, how do you set up the repeat function?
<orphanage>
<small-child id=1>
<name>Rajan</name>
<age>12<age>
</small-child>
<small-child id=2>
<name>John</name>
<age>8<age>
</small-child>
<small-child id=3>
<name>Jose</name>
<age>9<age>
</small-child>
</orphanage>
--
Om Shanti
Sivakatirswami
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode