Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:35:20+00:00 2026-05-28T07:35:20+00:00

xstream is converting & to & when converting from xml to Java Objects. I

  • 0

xstream is converting & to & when converting from xml to Java Objects.
I don’t want this to happen. How shall I do it?

 XStream xstream = new XStream(new DomDriver());

            xstream.processAnnotations(HelpConfigVO.class);
            xstream.processAnnotations(ProductVO.class);
            xstream.processAnnotations(PackageVO.class);
            xstream.addImplicitCollection(HelpConfigVO.class, "packages");
            configVO = (HelpConfigVO)xstream.fromXML(helpConfigData);

Secondly, The output XML I am getting from xstream is not formatted. How do I format my xml to make it readable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:35:21+00:00Added an answer on May 28, 2026 at 7:35 am

    xstream is converting "&" to "&" when converting from xml to Java Objects.

    As it should. It would be broken if it didn’t

    I don’t want this to happen.

    Why? The "&" in the XML means "&".

    How shall I do it?

    No valid XML parser will do this for you because it is an egregious violation of the XML spec. In theory, you could hack an open source XML parser to do this abominable act … but I’d strongly advise against it.


    If correct behavior in the parser is causing you problems, you’ve got a flaw in your application design. You should do something like:

    • not parsing the XML – store it as character sequence, OR

    • reinsert the character entities by applying the XML escape mapping to the text before you use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is how I create XStream instance for XML: XStream xstream = new XStream();
I am planning on using XStream with Java to convert between objects and XML
This code: println(new XStream.toXML(List(1,2,3))) produces this XML: <scala.coloncolon serialization=custom> <unserializable-parents/> <scala.coloncolon> <int>1</int> <int>2</int> <int>3</int>
I am using XStream to generate XML from several Java classes and I need
I would like to switch from Xstream to Jackson for serializing/deserializing objects in a
I am using XStream to serialize my Objects to XML format. The formatted xml
I'm trying out XStream as a way to quickly serialize objects to Xml or
We serialize/deserialize XML using XStream... and just got an OutOfMemory exception. Firstly I don't
We'd like to generate xml using xstream implemented with java. We'd then like to
I need to build an XML document from a Java object hierarchy. Both the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.