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

The Archive Base Latest Questions

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

I am using XMLOutputter class for writing Document object’s contents into a xml file.

  • 0

I am using XMLOutputter class for writing Document object’s contents into a xml file.

But i am facing below problem:
when i delete any child node, it creates blank line in Document object and while saving its contents into xml file, it displays blank line in xml file as well.

So it means that if i perform delete operation 10 time and saved its contents then there would be 10 blank lines in the xml file.

I went through the below links. These links suggest to use below api:

  1. http://www.jdom.org/pipermail/jdom-interest/2003-November/013035.html

this link suggest:

XMLOutputter fmt = new XMLOutputter();
fmt.setTextTrim(true);  //this would remove all spaces
fmt.setIndent("  ");    // this will do indentation
fmt.setNewlines(true);
  1. http://www.ibm.com/developerworks/xml/tutorials/xmljava/section5.html

    SAXBuilder sb = new SAXBuilder();

    Document doc = sb.build(new File(argv[0]));

    XMLOutputter xo = new XMLOutputter();

    xo.setTrimAllWhite(true);

    xo.output(doc, System.out);

Can some one help me regarding this issue.

Thanks in Advance !!

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

    Do you want to remove whitespace/blank lines, or do you want the output to be formatted nicely with correct indents etc.?

    To get nice indenting use the ‘pretty’ format?

    xo.setFormat(Format.getPrettyFormat());
    

    to strip all unnecessary whitespace use Format.getCompactFormat()

    rolfl

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

Sidebar

Related Questions

I want to send an xml document that i have created using jdom api.
Using C# How can I show a document in richtextbox without scrollbars, But I
i'm really new to C++-programming and i've got an a problem with writing into
Using C#.NET, i wrote a toolbar which is stored now into toolbar.cs file. I
Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files.
I am needing to log some xml data (which is currently a JDOM Document),
I have a bit of Java code that outputs an XML file to a
Using NLTK and WordNet , how do I convert simple tense verb into its
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
Using the DateTime class, if I try to run the following code: $mydate =

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.