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 7681149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:16:35+00:00 2026-05-31T18:16:35+00:00

I wanted to serialize a java class to XML with XStream. I needed to

  • 0

I wanted to serialize a java class to XML with XStream.

I needed to generated an XML element with one underline (canal_operateur), but XStream adds a second underline in the xml element name.

So how to keep only one underline ?

With the default configuration for this class :

public class Document implements Serializable {
    private String typedoc;
    private Fichier fichier;
    private String canalOperateur;  
    //xstream.aliasField("canal_operateur", Document.class, "canalOperateur");
    /*
    ** setter and getter
    */
}

XStream doubles the underline :

<document>
    <canal__operateur>canal</canal__operateur>
    <commentaire>commentaire</commentaire>
    <metadonnees/>
</document>
  • 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-31T18:16:36+00:00Added an answer on May 31, 2026 at 6:16 pm

    According to here:

    XStream maps Java class names and field names to XML tags or
    attributes. Unfortunately this mapping cannot be 1:1, since some
    characters used for identifiers in Java are invalid in XML names.
    Therefore XStream uses an XmlFriendlyNameCoder to replace these
    characters with a replacement. By default this NameCoder uses an
    underscore as escape character and has therefore to escape the
    underscore itself also. You may provide a different configured
    instance of the XmlFriendlyNameCoder or a complete different
    implementation like the NoNameCoder to prevent name coding at all.
    However it is your responsibility then to ensure, that the resulting
    names are valid for XML.

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

Sidebar

Related Questions

I wanted to generate one fix view using interface builder, but the size of
I'm using the java encog library and wanted to know how to serialize the
I wanted to serialize objects with XML, so I got TinyXML. However I went
I've always wanted to send objects that you can serialize in XML across websites,
I wanted to show the users Name Address (see www.ipchicken.com ), but the only
I wanted to emulate a popular flash game, Chrontron, in C++ and needed some
I've been working with Xml Serialization/Deserialization in .net and wanted a method where the
I want XML in the following format: <configuration><!-- Only one configuration node --> <logging>...</logging><!--
I simply wanted to serialize all the fields of a submitted form, like this
Wanted to convert <br/> <br/> <br/> <br/> <br/> into <br/>

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.