Skip to main content

handling xml with quotes escaped

Right now if the xml has quotes that are preceded with backslashes, the site does not recognize it as xml.

I am debugging code in ruby and when I do an xml request, the response is in this form

"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><feedMessageResponse><count>51</count><feed><id>0RWqSn8iuUFnoShnsm7Fjh2LaUslTu2nI</id><name>location</name><description>location</description><status>ACTIVE</status><usage>0</usage

It would be good for the site to detect this and convert it to normal text (replace \ā€ to just ā€œ and remove initial and ending quotes.

Right now is have to do ā€œputs variable_with_xmlā€ and then cut and paste that into the site.

Status: Completed5 comments

Log in to comment and vote

Comments5

  • @levelsio

    Team•

    Nov 29, 2024

    Hmm, no XML viewer online would accept that as valid XML though, so I not sure I wanna do this

    • Purple Blueberry

      •

      Nov 29, 2024

      It’s definitely not valid xml but it’s common to get strings back like this in most programming languages when you are in the debugger. It would just allow someone to cut and paste into json.pub without having to run it through a utility function. In ruby you currently have to do ā€œputs xml_strungā€ and then cut and paste that into JSON.pub. Same is true with any string that has a ā€œcharacter in it. It’s called escaped strings.

      Part of the reason I’m asking for this desire is that the idea is that json.pub is supposed to be better than the other tools

      My idea is you do a quick check to see if the string is escaped. If it is, then you either just convert it for the user (as it isn’t valid in its current format) or maybe ask a ser if they want the string in-escaped (although feel answer will always be yes).

      Anyways under it’s your app so respect whatever your final decision is

      • @levelsio

        Team•

        Nov 29, 2024

        True good point. So maybe we can check if it’s ā€œdataā€ and then remove the ā€œ

        Is it always ā€œ?

        • @levelsio

          Team•

          Nov 29, 2024

          Added now for you, let me know if it works!

          • Purple Blueberry

            •

            Nov 30, 2024

            Works for me. Awesome & thanks!