search for regular expression in text and put the results into an array

3 messages Options
Embed this post
Permalink
runrev260805

search for regular expression in text and put the results into an array

Reply Threaded More More options
Print post
Permalink
Hi,

I am absolutely new to XML, so please forgive me for this question.

I have an XML file which looks similar like this.

<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>blah blah bla
   <some other>blah blah blah
      <and so on></status>


The <status>...</status> part is repeating many times, but with different content.

i want to put the <status>...</status>part  into an array. So i get to know how often this part is in the xml file. I then want to extract some text of each of this <status>....</status> section. My main problem is how to seperate each <Status...> </status> section. Do i have to use the XML library? Or is there another way?

Regards,

Matthias


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Sarah Reichelt-2

Re: search for regular expression in text and put the results into an array

Reply Threaded More More options
Print post
Permalink
> I have an XML file which looks similar like this.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <statuses type="array">
> <status>blah blah bla
>   <some other>blah blah blah
>      <and so on></status>
>
>
> The <status>...</status> part is repeating many times, but with different content.
>
> i want to put the <status>...</status>part  into an array. So i get to know how often this part is in the xml file. I then want to extract some text of each of this <status>....</status> section. My main problem is how to seperate each <Status...> </status> section. Do i have to use the XML library? Or is there another way?


You can use the XML library, but for this case, it's probably just as
easy to use standard chunking commands.
Assuming you have the XML in a variable, you can loop through getting
the offset of <status> and the offset of </status> and getting what is
in between until there are no more to be found.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Jim Ault

Re: search for regular expression in text and put the results into an array

Reply Threaded More More options
Print post
Permalink
In reply to this post by runrev260805
I don't use the xml library to do the simple tag processing for three  
types of tags
Chunk expressions are so fast that I get better speed and control of  
the data parsing.

------- Use these steps to get started----

on test
    replace cr with empty in xmlBlock
    replace quote with "'" in xmlBlock  --(apostrophe ' char)
    --now you can use quote expressions without worries
    --   such as in the next line
    replace "<statuses type='array'>" with (cr & "<statuses  
type='array'>") in xmlBlock
    filter xmlBlock with "<statuses type='array'>*"

    put 0 into statusCount
    repeat for each line statusArrLine in xmlBlock
       replace "<status>" with (cr & "<status>") in statusArrLine
       replace "</status>" with ("</status>" & cr) in statusArrLine
       filter statusArrLine with "<status>*"

       repeat for each line statusTag in statusArrLine
          replace "<status>" with empty in statusTag
          replace "</status>" with empty in statusTag
          --now we have the data only, and on a single line
          add 1 to statusCount
          put statusTag into storArray[statusCount]

       end repeat
    end repeat

    --> statusCount = total
    --> storArray[num] = strings storage
end test

Hope this helps.

Jim Ault
Las Vegas

On Nov 4, 2009, at 4:06 PM, [hidden email] wrote:

> Hi,
>
> I am absolutely new to XML, so please forgive me for this question.
>
> I have an XML file which looks similar like this.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <statuses type="array">
> <status>blah blah bla
>   <some other>blah blah blah
>      <and so on></status>
>
>
> The <status>...</status> part is repeating many times, but with  
> different content.
>
> i want to put the <status>...</status>part  into an array. So i get  
> to know how often this part is in the xml file. I then want to  
> extract some text of each of this <status>....</status> section. My  
> main problem is how to seperate each <Status...> </status> section.  
> Do i have to use the XML library? Or is there another way?
>
> Regards,
>
> Matthias




_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution