FAQ
http://play.golang.org/p/3Nbkup5fOa

I'm trying to embed a JSON document as a value of an XML element - when
Marshaling the XML document, it escapes the JSON string - how can I prevent
this?

I want the result to look like:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <elem>
     <Files>{"FileName":"hello","ID":"world"}</Files>

   </elem>
</Package>


instead of:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <elem>
     <Files>{&#34;FileName&#34;:&#34;hello&#34;,&#34;ID&#34;:&#34;world&#34;}</Files>
   </elem>
</Package>


Thanks!

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Henrik Johansson at Sep 16, 2014 at 8:50 pm
    cdata perhaps?
    On Sep 16, 2014 10:36 PM, "sc28" wrote:

    http://play.golang.org/p/3Nbkup5fOa

    I'm trying to embed a JSON document as a value of an XML element - when
    Marshaling the XML document, it escapes the JSON string - how can I prevent
    this?

    I want the result to look like:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{"FileName":"hello","ID":"world"}</Files>

    </elem>
    </Package>


    instead of:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{&#34;FileName&#34;:&#34;hello&#34;,&#34;ID&#34;:&#34;world&#34;}</Files>
    </elem>
    </Package>


    Thanks!

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • C Banning at Sep 17, 2014 at 8:45 am
    http://play.golang.org/p/g-IuAHRdjc
    On Tuesday, September 16, 2014 3:36:09 PM UTC-5, sc28 wrote:

    http://play.golang.org/p/3Nbkup5fOa

    I'm trying to embed a JSON document as a value of an XML element - when
    Marshaling the XML document, it escapes the JSON string - how can I prevent
    this?

    I want the result to look like:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{"FileName":"hello","ID":"world"}</Files>

    </elem>
    </Package>


    instead of:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{&#34;FileName&#34;:&#34;hello&#34;,&#34;ID&#34;:&#34;world&#34;}</Files>
    </elem>
    </Package>


    Thanks!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sc28 at Sep 17, 2014 at 1:30 pm
    Thanks All!

    For my case, the htmlUnescapeString function works perfectly.
    http://play.golang.org/p/e6-LgJJFXJ

    On Tuesday, September 16, 2014 4:36:09 PM UTC-4, sc28 wrote:

    http://play.golang.org/p/3Nbkup5fOa

    I'm trying to embed a JSON document as a value of an XML element - when
    Marshaling the XML document, it escapes the JSON string - how can I prevent
    this?

    I want the result to look like:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{"FileName":"hello","ID":"world"}</Files>

    </elem>
    </Package>


    instead of:

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <elem>
    <Files>{&#34;FileName&#34;:&#34;hello&#34;,&#34;ID&#34;:&#34;world&#34;}</Files>
    </elem>
    </Package>


    Thanks!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 16, '14 at 8:36p
activeSep 17, '14 at 1:30p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase