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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:01:20+00:00 2026-06-18T11:01:20+00:00

I am creating a com.w3c.dom.Document from a String using this code: DocumentBuilderFactory docFactory =

  • 0

I am creating a com.w3c.dom.Document from a String using this code:

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new InputSource(new StringReader("<a><b id="5"/></a>")));

When I System.out.println(xmlToString(document)), I get this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><a><b id="5"/></a>

Everything is ok, but I don’t want the XML to have the <?xml version="1.0" encoding="UTF-8" standalone="no"?> declaration, because I have to sign the with private key and embed to soap envelope.

  • 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-18T11:01:21+00:00Added an answer on June 18, 2026 at 11:01 am

    You could use a Transformer and set the OutputKeys.OMIT_XML_DECLARATION property to "yes":

    Transformer t = TransformerFactory.newInstance().newTransformer();
    t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    StringWriter sw = new StringWriter();
    t.transform(new DOMSource(doc), new StreamResult(sw));
    

    Please note you could also:

    • Use a StreamSource instead of a DOMSource to feed the String directly to the transformer, if you don’t really need the Document.
    • Use a DOMResult instead of a StreamResult if you wanted to output a Document.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this tutorial: http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ I have created sample/hello world application on the windows phone
I am using this tutorial: http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-rotating-dialer/ Which gives me a rotating dialer based on
The following code is from a tutorial ( http://net.tutsplus.com/php/creating-a-php5-framework-part-1/ ), not mine. I have
I followed this screencast to make a erb:to:haml rake task: http://teachmetocode.com/screencasts/creating-a-rake-task-to-convert-erb-to-haml/ I backed everything
I am creating a dialog like in this page: http://jqueryui.com/demos/dialog/#modal-confirmation (click view source) on
I was looking at stockcharts - http://code.google.com/p/stock-chart for creating candlestickgraphs in my application. I
I am creating a web app, similar to the like box code from Facebook:
I am creating a COM server using C++ Builder XE. Its ProgID is always
I'm trying to use this tweak for my blog: http://www.tonylea.com/2011/creating-a-jquery-exit-popup/#comment-909 Basically what it does
. I found sample called Creating a COM Server Using a Text Editor in

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.