Page 1 of 1

parsing the tags out of an XML file

Posted: Wed Nov 10, 2010 1:26 am
by adventuresofgreg
Hello: What is the fastest way to parse out these XML tags from some futures price data?

<Date>11/3/2010</Date>
<Open>1197.5</Open>
<High>1198</High>
<Low>1196</Low>
<Last>1197.25</Last>
<Settle>1197.25</Settle>
<Volume>2361808</Volume>
<OpenInterest>2683550</OpenInterest>

It would be cool if you could set the itemdelimiter to an entire string rather than just one character - like in this case, if I could set the item delimiter to <anything>, then just replace all the item delimiters with ","'s

Re: parsing the tags out of an XML file

Posted: Wed Nov 10, 2010 1:35 am
by Mark
adventuresofgreg,

Let's assume that fld 2 contains your XML...

Code: Select all

on mouseUp
     put "<p>" & fld 2 & "</p>" into myHtml
     replace cr with "</p><p>" in myHtml
     set the htmlText of fld 1 to myHtml
end mouseUp
Kind regards,

Mark

Re: parsing the tags out of an XML file

Posted: Wed Nov 10, 2010 1:49 am
by adventuresofgreg
wow - thanks Mark! That's so simple - and fast. Now I just have to try to understand it... I'll look up htmlText. I want to convert each date of prices to the standard:

date,prices,return
date, prices, return
etc...
Mark wrote:adventuresofgreg,

Let's assume that fld 2 contains your XML...

Code: Select all

on mouseUp
     put "<p>" & fld 2 & "</p>" into myHtml
     replace cr with "</p><p>" in myHtml
     set the htmlText of fld 1 to myHtml
end mouseUp
Kind regards,

Mark

Re: parsing the tags out of an XML file

Posted: Sun Nov 14, 2010 12:30 pm
by Klaus
Hi Greg,

looks like you need to dive a bit deeper into XML :D
Of course you could do some chunk stuff within a repeat loop,
but to be prepared for the future you should take the dive!

Please check the wonderful stack "xmldemo1" on this site:
http://www.troz.net/rev/
This got me started with XML, too!


Best

Klaus