Retrieving text within 2 tags

Jim Ault JimAultWins at yahoo.com
Fri Aug 1 20:49:56 EDT 2008


On 8/1/08 4:34 PM, "mfstuart" <mfstuart at cox.net> wrote:
> The text originated from a web site, using command "put url theURL into
> tData".
<full quote below>

When ever I retrieve tags from a source I did not create,  I use

put url theURL into xmlBlock
replace cr with empty  in xmlBlock  --Rev uses char (10) = cr
replace numtochar(13) with empty  in xmlBlock

Now your text is all in a single line

replace "<" with (cr & "<") in xmlBlock
--now each tag of any kind is on a separate line

-------or  ------ for your specific case-----
replace "<MyText>" with  (cr & "<MyText>") in xmlBlock
replace "</MyText>" with ("<" & cr) in xmlBlock
filter xmlBlock with ("*<MyText>*")

--now ALL the remaining lines in xmlBlock are the tags you wanted

Eric Chatonet wrote at least one tutorial stack on how to get data from html
text.  He has written a cleaner function that does a great job.  I don't
remember just where it is, but it is a winner.

Also, Hugh Senior (Scripter's Scrapbook) probably has a few library routines
you could use that are good cleaner functions.

> I don't know how to use the XML commands in rev as yet (a possibility), so I
> would like to use the text chunk commands to do so.
The XML in Rev has been a slow way of parsing XML in my experience, and the
best place I know is Ken Ray's SonsOThunder.com and his XML parser library.
It would have the best speed and is kept up-to-date.


Jim Ault
Las Vegas
 


On 8/1/08 4:34 PM, "mfstuart" <mfstuart at cox.net> wrote:

> 
> Hi all,
> 
> RunRev: 2.90
> OS: WinXP
> 
> How would I retrieve text that is within 2 tags, that has been put into a
> memory variable?
> The text originated from a web site, using command "put url theURL into
> tData".
> Such as:
> 
> <MyText>
> This is some text I would like to
> retrieve. It is on many lines
> and all the text has to be return
> within the tags.
> 
> Also, the text could have HTML formatting in it.
> </MyText>
> 
> I don't know how to use the XML commands in rev as yet (a possibility), so I
> would like to use the text chunk commands to do so.
> 
> TIA.
> Mark Stuart





More information about the use-livecode mailing list