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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:31:48+00:00 2026-06-03T00:31:48+00:00

I am writing some code that talks to a legacy system that needs the

  • 0

I am writing some code that talks to a legacy system that needs the following element:

<BankRate><![CDATA[        ]]><BankRate>

I can’t for the life of me get this working, my attempt so far is:

parent.setBankRate("    ");
XmlCursor cursor = cc.xgetBankRate().newCursor();
cursor.toFirstContentToken();
cursor.setBookmark(CDataBookmark.CDATA_BOOKMARK);
cursor.dispose();

This simply results in the following:

<BankRate><BankRate>

The options for the parent is:
setSaveCDataEntityCountThreshold(0).setSaveCDataLengthThreshold(0);

If I setBankRate like the following:

cc.setBankRate("<![CDATA[        ]]>");

I get character entities (which is not what I want)

  • 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-06-03T00:31:49+00:00Added an answer on June 3, 2026 at 12:31 am

    I tried the following test:

    import org.apache.xmlbeans.*;
    
    public class main {
        public static void main ( String[] args ) throws XmlException {
            XmlObject x = XmlObject.Factory.parse( "<BankRate>        </BankRate>" );
            XmlCursor c = x.newCursor();
            c.toFirstContentToken();
            c.toNextToken();
            c.setBookmark(CDataBookmark.CDATA_BOOKMARK);
            XmlOptions options = new XmlOptions();
            options.setSaveCDataLengthThreshold( 1 );
            options.setUseCDataBookmarks();
            System.out.print( x.xmlText( options ) );
        }
    }
    

    The result is:

    <BankRate><![CDATA[        ]]></BankRate>
    

    If your goal is to force the saving of the contents of BankRate as CDATA, this is how you do it.

    However, if this does not work, and you get nothing (the empty element) as the value of BankRate, then what is probably happening is that the BankRate Type is not text, and is some other type which ignores white space. If you really need to get whitespace as the value of BankRate, you will have to inject it with an XmlCursor.

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

Sidebar

Related Questions

I am writing some code that needs to be backwards compatible with EXISTING remoting
I am writing some code that can migrate some device persisted data to a
I'm writing some server code that talks to a client process via STDIN. I'm
I'm writing some code that has a lot of substitution. There's a list<char> productions
I am writing some code that connects to a website, and using C#, and
I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE:
I'm writing some code that takes a report from the mainframe and converts it
I'm writing some code that uses some unmanaged calls into user32 functions such as
I'm writing some code that will serialize a C# object to JSON, send it
I'm writing some code so that at each iteration of a for loop it

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.