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

  • SEARCH
  • Home
  • 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 620103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:43:38+00:00 2026-05-13T18:43:38+00:00

Alright, so here is my issue. I need to generate xml in Java to

  • 0

Alright, so here is my issue. I need to generate xml in Java to pass onto another application. I started off thinking this would be easy using an org.w3c.dom.Document. Unfortunately the application I need to pass the XML off to requires that special characters like ” need to be encoded as ASCII (") instead of their character entity ("). Does anybody know a simple solution to this?

P.S. Changing the target application is not an option.

Update:
So let’s say my app is given the following string as input:

he will "x" this if needed

My app needs to output this:

<field value="he will &#034;x&#034; this if needed"/>

The XML generator I am using and I am guessing most others output this but this is not valid for my target:

<field value="he will &quot;x&quot; this if needed"/>

I realize my target may not quite be up to XML standards, but that doesn’t help me as I have no control over it. This is my situation and I have to deal with it. Any ideas other than simply converting every special character by hand?

  • 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-13T18:43:39+00:00Added an answer on May 13, 2026 at 6:43 pm

    I wonder how you serialize the XML–to a string, a stream, etc. You can post-process your output to replace general entity references with their numeric equivalents, e.g.,

    sed 's/&lt;/\&#60;/g; s/&gt;/\&#62;/g; s/&amp;/\&#38;/g; s/&apos;/\&#39/g; s/&quot;/\&#34;/g'

    or

    xmlResultString.replaceAll("&lt;", "&#60;"); //etc. for other entities

    There are exactly 5 pre-defined general entities in XML (http://www.w3.org/TR/REC-xml/#sec-predefined-ent) and you can safely perform this as a textual replacement. There is no danger that it modify anything except the references (well, maybe in comments and PIs, but it doesn’t sound like your scenario uses them, or that the target even accepts them).

    I agree with Mark that your target application is not a conforming XML processor. At least it comes with documentation that states explicitly where it diverges from XML. I believe the Recommendation (link above) disagrees with Christopher’s comment, though it’s irrelevant to OP’s question as his target declares its non-conformance to the Recommendation.

    Ari.

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Google Maps API Docs have what seems to be… May 16, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer It's a server's business. PHP has a "garbage collector" mechanism… May 16, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer First, create three classes: Gesellschaft, Anschrift, and Email. These classes… May 16, 2026 at 3:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Alright, I'm at my wit's end on this issue. First, backstory. I'm working on
Alright so here is my issue. I'm working a game engine that will eventually
Alright, here is a link to the site I am working on. http://danberinger.com/preview.html I
Alright, PHP is throwing this error (in the log) and it's quite detrimental to
Alright I'm a bit baffled by this one. Changing an unrelated int property on
Alright, I don't know if anyone has tried to do this yet, however. I
Alright, I'm confused as hell. I have an object that I store in a
Alright...I've given the site a fair search and have read over many posts about
I have a 3 file program, basically teaching myself c++. I have an issue.
Alright, so I've been doing some poking around, and I realize my problem, but

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.