existing methods to unescape XML escaped characters.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

existing methods to unescape XML escaped characters.

Squeak - Dev mailing list
Hi Folks,

I am storing parsed content from XTreams parsing in the XMLElement that Xtreams parsing uses....(could be different from stock Squeak XML package per recent discussion here.)


To get my content to display properly on Chrome, I have to unescape the escaped XML escaped characters.

I wrote a quick and dirty method to git-r-done....


unEscapeXMLEscapeCharaters: aString |xmls| xmls := aString copyReplaceAll:'&gt;' with:'>' asTokens:false. xmls := xmls copyReplaceAll:'&lt;' with:'<' asTokens:false. xmls := xmls copyReplaceAll:'&quote;' with:'"' asTokens:false. xmls := xmls copyReplaceAll:'&apos;' with:'''' asTokens:false. xmls := xmls copyReplaceAll:'&amp;' with:'&' asTokens:false. ^xmls

However, I have a nagging suspicion I have re-invented the wheel; although I did spend significant time hunting for one.

If anything obvious jumps out, please respond.

thx.





Reply | Threaded
Open this post in threaded view
|

Re: existing methods to unescape XML escaped characters.

Davide Grandi-3

... I'd look for apos - quotes - amp - gt - lt in sources and changes.
... or directly in String instances and then in their references ... looking for compiled methods, blocks and so on.
(a dirty reinvented wheels to run on a muddy road)

    davide

On 15/11/2020 19:52, gettimothy via Squeak-dev wrote:
Hi Folks,

I am storing parsed content from XTreams parsing in the XMLElement that Xtreams parsing uses....(could be different from stock Squeak XML package per recent discussion here.)


To get my content to display properly on Chrome, I have to unescape the escaped XML escaped characters.

I wrote a quick and dirty method to git-r-done....


unEscapeXMLEscapeCharaters: aString |xmls| xmls := aString copyReplaceAll:'&gt;' with:'>' asTokens:false. xmls := xmls copyReplaceAll:'&lt;' with:'<' asTokens:false. xmls := xmls copyReplaceAll:'&quote;' with:'"' asTokens:false. xmls := xmls copyReplaceAll:'&apos;' with:'''' asTokens:false. xmls := xmls copyReplaceAll:'&amp;' with:'&' asTokens:false. ^xmls

However, I have a nagging suspicion I have re-invented the wheel; although I did spend significant time hunting for one.

If anything obvious jumps out, please respond.

thx.





    
-- 
Ing. Davide Grandi
email    : [hidden email]
linkedin : http://linkedin.com/in/davidegrandi