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

2007-01-17 Thread Ken Ray


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()  --> list of article titles
   stsXML_GetRSSItemProperty(,)  -->  
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: [EMAIL PROTECTED]

(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 )
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


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

2007-01-16 Thread Derek Bump

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. ;)


Thanks to everyone that helped me out.  I really appreciate it!


Derek Bump
Dreamscape Software
http://www.dreamscapesoftware.com/
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


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

2007-01-15 Thread Martin Blackman

I reckon people get put off by the long revXML function names and all
the parameters. But if you are fortunate enough to have Galaxy, it
makes things easier - you type the first few characters then use the
autocomplete function!
Before long you will find loops such as the following to be second nature:

put revXMLrootnode(tID) into tnode
put revXMLfirstchild(tID,tnode) into paramNode
repeat
   get revXMLAttribute(tID,paramNode,"name")
   if not (it contains "xmlerr") then
  put it into tname
  put tname & comma after tparamlist
   end if
put revXMLNextSibling(tID,paramNode) into paramNode
if paramNode is empty then exit repeat
end repeat
delete char -1 of tparamlist

regards
Martin
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


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

2007-01-14 Thread Sarah Reichelt

On 1/15/07, Derek Bump <[EMAIL PROTECTED]> wrote:

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: Google
get matchText(tData,"(.*)", tShortName)

But I start running into problems with tags that have attributes:

http://www.whatever.com/search";>


And tags that have attributes AND "slashes" at the end:

   http://www.whatever.com/search"/>



Hi Derek,

I tried saving your XML as a text file with the official XML header:


http://www.google.com/search";>
 
 
 
 
 
 


Then I opened it using the XML construction kit that is part of my XML
demo .

It worked perfectly and I was able to extract all the elements & their
attributes perfectly. While the XML library has a learning curve, I
would recommend that you use it for such parsing. Or use Ken Ray's
third-party XML library.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


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

2007-01-14 Thread Derek Bump
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: Google
   get matchText(tData,"(.*)", tShortName)

But I start running into problems with tags that have attributes:

   http://www.whatever.com/search";>
   

And tags that have attributes AND "slashes" at the end:

  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:

http://www.google.com/search";>
  
  
  
  
  value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
  trueValue="firefox-a" falseValue="firefox"/>



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/


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution