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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:07:39+00:00 2026-06-01T10:07:39+00:00

I am using the IndentingXMLStreamWriter-Class to get a well formatted XML-file. The code looks

  • 0

I am using the IndentingXMLStreamWriter-Class to get a well formatted XML-file. The code looks like this:

XMLOutputFactory output = XMLOutputFactory.newInstance();
XMLStreamWriter streamWriter;
IndentingXMLStreamWriter indentingStreamWriter;
streamWriter = output.createXMLStreamWriter(new FileOutputStream(fileName));
indentingStreamWriter = new IndentingXMLStreamWriter(streamWriter);
indentingStreamWriter.setIndentStep("    "); 
indentingStreamWriter.writeStartDocument("UTF-8", "1.0"); 

The size and depth of the generated XML is very large. When I use the indenting streamwriter the size of the file is more than twice as large as the file generated with the “normal” streamwriter. Is there are better way to realize the indenting or am i doing something wrong?

Thanks in advance

Lars

Update:
dty is -of course- absolutely right. I am asking myself if it is a good idea to do the indenting in a more compact way (e.g. tab characters). Any ideas or suggestions?

  • 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-01T10:07:41+00:00Added an answer on June 1, 2026 at 10:07 am

    At the risk of sounding stupid, you’re taking a file of XML and adding indenting (4 characters per level) and newlines (presumably). It’s going to get bigger.

    How much bigger depends on how big the XML tags are and how deeply nested they are. If they tags are quite small, then the relative size of the whitespace is quite large and could conceivably double the size of the file. If they’re deeply nested, you’ll be adding lots of space to each line.

    You don’t appear to have many options if you want a pretty-printed document. You could use fewer spaces (2 instead of 4), or even tab characters (although the next guy might shoot you for doing so), but, really, I think this is a case of c’est la vie.

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

Sidebar

Related Questions

Using the HTML5 File API I can get the Binary String representation of a
Using NSDateComponents I know how to get the day component, but this gives me
Using this code, the following execution yields strange results: C 100 R W The
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
using file_get_contents , I open an Internet URL and get the contents of this
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Using File.AppendAllText(c:\mytextfile.text, This is the first line) File.AppendAllText(c:\mytextfile.text, This is the second line) How
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
Using Rails 3.2.0 with haml and sass: I Would like to link an external

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.