existing utility class to escape/unescape xml

Discussion in 'Java' started by NetKev, Mar 4, 2008.

  1. NetKev

    NetKev Guest

    I use JAXB to stuff some data into xml and pass it on to a client-side
    ajax application. I'm thinking I need to escape the data before
    stuffing it in. Are there any available utility classes to do this?
    I will eventually need to do the reverse when I get data from the
    client app.

    Incidentally, I need to do the same thing in javascript on the client
    side and it needs to be compatible with the java implementation. Any
    pointers for that will help me as well.

    -Kevin
    NetKev, Mar 4, 2008
    #1
    1. Advertising

  2. On Mar 4, 4:30 pm, NetKev <> wrote:
    > I use JAXB to stuff some data into xml and pass it on to a client-side
    > ajax application.  I'm thinking I need to escape the data before
    > stuffing it in.  Are there any available utility classes to do this?
    > I will eventually need to do the reverse when I get data from the
    > client app.
    >
    > Incidentally, I need to do the same thing in javascript on the client
    > side and it needs to be compatible with the java implementation.  Any
    > pointers for that will help me as well.
    >
    > -Kevin


    JAXB handles this for you. So do the underlying DOM APIs. So does
    SAX, if you want to go that way. Pretty much any sensible API for
    processing XML will automatically translate between the value of an
    attribute or text node (which does not contain escape sequences) and
    the representation (which does).

    Thus, if you serialize a bean containing the string "foo & bar" as a
    field value using JAXB, the resulting XML should contain "foo &amp;
    bar" in the appropriate place.

    -o
    Owen Jacobson, Mar 4, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SGFycnkgS2Vjaw==?=

    What is the .Net equivalent of jscript escape/unescape?

    =?Utf-8?B?SGFycnkgS2Vjaw==?=, Mar 9, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,836
    =?Utf-8?B?VGltIFN0YWxs?=
    Mar 9, 2005
  2. Jon Stenqvist

    Unescape xml element content

    Jon Stenqvist, Jul 11, 2008, in forum: Ruby
    Replies:
    2
    Views:
    158
    matt neuburg
    Jul 11, 2008
  3. Tony Augustine
    Replies:
    0
    Views:
    350
    Tony Augustine
    Jul 22, 2010
  4. Philipp

    Escape/ Unescape HTML?

    Philipp, Dec 20, 2007, in forum: Javascript
    Replies:
    2
    Views:
    239
    Thomas 'PointedEars' Lahn
    Dec 21, 2007
  5. RK
    Replies:
    1
    Views:
    131
    Gabriel Gilini
    Nov 12, 2008
Loading...

Share This Page