Dr. Strangelove (or: How I Learned to Stop Worrying and Love XML)
Derek Bump
list at dreamscapesoftware.com
Sun Jan 14 16:37:10 EST 2007
Well, I'm a little behind the game, but I'm trying to work with XML
documents, and I'm running into walls. I am having difficulty
understanding all the different variations of XML, or for that matter,
making Regular Expressions that allow me to forget trying to understand
XML and just pull the data I need.
For example, I can get tags with no problems by using the following command:
-- Example: <ShortName>Google</ShortName>
get matchText(tData,"<Shortname>(.*)</Shortname>", tShortName)
But I start running into problems with tags that have attributes:
<Url type="text/html" template="http://www.whatever.com/search">
</Url>
And tags that have attributes AND "slashes" at the end:
<Url type="text/html" template="http://www.whatever.com/search"/>
Using Regular Expressions on "unpredictable" tags with attributes,
nodes, parents, children, grandchildren, aunts, uncles and every other
branch of the family tree will only result in problems (as with any
large family).
Is there any easy way of pulling data from XML? The XML library is
definitely not what I would call easy, which is really a shame
considering how easy Revolution has always been.
So what's the hangup? I'm trying to parse the following data:
<Url type="text/html" method="GET" template="http://www.google.com/search">
<Param name="q" value="{searchTerms}"/>
<Param name="ie" value="utf-8"/>
<Param name="oe" value="utf-8"/>
<!-- Dynamic parameters -->
<Param name="rls"
value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
<MozParam name="client" condition="defaultEngine"
trueValue="firefox-a" falseValue="firefox"/>
</Url>
Am I better off parsing with Revolution's XML code or just using offset,
matchText and some regular expressions?
Derek Bump
Dreamscape Software
http://www.dreamscapesoftware.com/
More information about the use-livecode
mailing list