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

The Archive Base Latest Questions

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

I want to print my output xml in a single line[when viewed in notepad

  • 0

I want to print my output xml in a single line[when viewed in notepad or other simple text-editor], so as to remove the redundant white-space in my xml file. So which is the better method to follow for that ??

I think there are two options,
1) To use

  <xsl:output method="xml" indent="no"/>

2) or to use

  <xsl:strip-space elements="*"/>

Which is more efficient, and why?

some people suggest me to use indent="no",

I believed that strip-space is best suited, but not sure because of suggestions given by others.

To be more elaborated let me take an example:

Input XML:

<root>
 <node>
   <child1/>
   <child2/>
 </node>
</root>

and the output required is:

<root><node><child1/><child2/></node></root>
  • 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-13T19:27:43+00:00Added an answer on May 13, 2026 at 7:27 pm

    In order to eliminate anything that looks like “indentation” it may be necessary (that means there are cases when you need) to use both <xsl:strip-space> and “indent=”no”`.

    Take the simplest example: you have the identity transformation. Without any of the two methods specified, the transformation will reproduce the white-space-only text nodes from the source XML document. That is, if the source XML document is indented, the transformation will produce indented result, too.

    Now, add to this transformation <xsl:output indent="no" />. This instructs the XSLT processor not to perform “pretty-printing” of its own. However, the whitespace-only nodes from the source XML document are still copied to the output and the result document looks still indented (because the source document is indented).

    Now, as a last step, add <xsl:strip-space elements="*"/>. You have specified both methods of preventing white-space-only nodes in the output. What happens? No white-space-only nodes are processed at all by the XSLT processor, and it does not indent the output — you get your desired one-line dense output.

    Finally, make a regression, change the <xsl:output indent="no" /> to <xsl:output indent="yes" />. The <xsl:strip-space elements="*"/> is still there, so no whitespace-only nodes are reproduced in the output. But the XSLT processor obeys the <xsl:output indent="yes" /> directive and adds whitespace-only text nodes of its own.

    So, from the four possible combinations, only specifying both <xsl:strip-space elements="*"/> and <xsl:output indent="no" /> guarantees that no indentation will be caused either from whitespace-only nodes from the source XML document or from the XSLT processors initiative.

    Even this last case, of course, doesn’t completely guarantee that the output won’t be indented — if the XSLT programmer intentionally puts there indentation code such as

    <xsl:text>

    </xsl:text>

    the output will contain this indentation.

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

Sidebar

Related Questions

I want to print each element of an xml document on a new line
I want to print columnar output from a ruby program, but in order to
I have a typical pom.xml, and want to print the groupId, artifactId and version,
I have the following very simple XML file and I want to quickly parse
The php script parses xml file and print output on page inside div: <?php
I have the following xml file: <root> <sub type=print>print</sub> <sub type=email>email</sub> </root> I want
Quick question: Is there a way to print raw input/output XML on a C#/.NET
I am trying to print the different category's selected in a single line in
I want to output raw xml in a manner similar to http://www.google.com/ig/api?weather=Mountain+View but using
I am reading xml gps data using xmlreader.read(). I want to output all coordinate

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.