Dr. Strangelove (or: How I Learned to Stop Worrying and Love XML)

Ken Ray kray at sonsothunder.com
Wed Jan 17 10:05:45 EST 2007


On Jan 16, 2007, at 7:38 PM, Derek Bump wrote:

> Bill Marriott wrote:
>> I can say that once you figure out what two or three commands you  
>> need to use to parse an XML file, it's way faster than using chunk  
>> expressions or some other method.
>
> This is really what I ended up doing.  I created my own "ripText"  
> function which pulls the data I need, via offsets, provided it  
> follows the XML format's rules.  If it doesn't, I throw an error.   
> And since it's standardized (it's the OpenSearch format), any  
> errors generated are the result of the XML author and not my program.
>
> I tried Sarah's stack and was amazed as to how nicely it parses the  
> XML, but I found that incorporating all of the RevXML commands into  
> what should be a simple function was all too complicated (not  
> Sarah's stack, but RevXML itself).
>
> There's a learning curve, and you're right, XML can get quite  
> complicated depending on who's writing it.  I mean look at RSS...  
> depending on the version: you could be there for hours. ;)

True! That's why I wrote a simple plugin to my XML parsing library  
for dealing with RSS feeds, so you could do things like:

    stsXML_GetRSSItemTitles(<channelNumber>)  --> list of article titles
    stsXML_GetRSSItemProperty(<titleOfArticle>,<property>)  -->  
retrieves a property for an item

So you can do something like this:

    put stsXML_GetRSSItemProperty("MyApp receives kudos at MacWorld  
Expo","link") into tURL
    revGoURL tURL

:-)


Ken Ray
Sons of Thunder Software, Inc.
Web Site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com

(BTW: If anyone's interested in my parsing library or the RSS Plugin,  
you can take a look at:
      http://www.sonsothunder.com/products/xmllib/xmllib.htm
      http://www.sonsothunder.com/products/xmllib/xmllib_rssplugin.htm )



More information about the use-livecode mailing list