Getting the URL out of <![CDATA[

Kay C Lan lan.kc.macmail at gmail.com
Fri Jan 16 21:28:40 EST 2015


If the above format is EXACTLY as the data appears, i.e.

<![CDATA[   --this is exact
--random URL you want to capture
]]>  --this is exact

then this is a very easy to parse. If the line above and below the random
URL is not as you've stated then there are other ways to skin the cat.

on mouseUp
   put URL tPathToXMLFile into tData
   put false into tParse
   put empty into tOutput
   repeat for each line tLine in tData
      switch
         case (tLine = "]]>")
            put false into tParse
            break
         case (tLine = "<![CDATA[")
            put true into tParse
            break
         case (tParse = false)
            --don't need to do anything
            break
         case (tParse = true)
            put tLine & cr after tOutput
            break
         default --this is here mainly for the development process
            answer warning "A Case I haven't considered." titled "Switch
Error"
            breakpoint
      end switch
   end repeat
   --strip the trailing cr
   put word 1 to -1 of tOutput into tOutput
   --put tOutput into where ever you like
end mouseUp



More information about the use-livecode mailing list