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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:45:56+00:00 2026-05-14T06:45:56+00:00

I am searching for an XSLT or command-line tool (or C# code that can

  • 0

I am searching for an XSLT or command-line tool (or C# code that can be made into a command-line tool, etc) for Windows that will do XML pretty-printing. Specifically, I want one that has the ability to put attributes one-to-a-line, something like:

<Node>
   <ChildNode 
      value1='5'
      value2='6'
      value3='happy' />
</Node>

It doesn’t have to be EXACTLY like that, but I want to use it for an XML file that has nodes with dozens of attributes and spreading them across multiple lines makes them easier to read, edit, and text-diff.

NOTE: I think my preferred solution is an XSLT sheet I can pass through a C# method, though a Windows command-line tool is good too.

  • 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-14T06:45:57+00:00Added an answer on May 14, 2026 at 6:45 am

    Here’s a small C# sample, which can be used directly by your code, or built into an exe and called at the comand-line as “myexe from.xml to.xml“:

        using System.Xml;
    
        static void Main(string[] args)
        {
            XmlWriterSettings settings = new XmlWriterSettings {
                NewLineHandling = NewLineHandling.Entitize,
                NewLineOnAttributes = true, Indent = true, IndentChars = "  ",
                NewLineChars = Environment.NewLine
            };
    
            using (XmlReader reader = XmlReader.Create(args[0]))
            using (XmlWriter writer = XmlWriter.Create(args[1], settings)) {
                writer.WriteNode(reader, false);
                writer.Close();
            }
        }
    

    Sample input:

    <Node><ChildNode value1='5' value2='6' value3='happy' /></Node>
    

    Sample output (note you can remove the <?xml ... with settings.OmitXmlDeclaration):

    <?xml version="1.0" encoding="utf-8"?>
    <Node>
      <ChildNode
        value1="5"
        value2="6"
        value3="happy" />
    </Node>
    

    Note that if you want a string rather than write to a file, just swap with StringBuilder:

    StringBuilder sb = new StringBuilder();
    using (XmlReader reader = XmlReader.Create(new StringReader(oldXml)))
    using (XmlWriter writer = XmlWriter.Create(sb, settings)) {
        writer.WriteNode(reader, false);
        writer.Close();
    }
    string newXml = sb.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am searching for a lib or tool or even some simple code that
I am writing an application that converts an ajax xml response into html using
I´m searching some providers or frameworks or something that can deliver a map like
I searching to get all contents that are tagged with some Tags. $OR can't
Searching for values that uses the same value Example SELECT Name, UnitPrice, Quantity, Color
Searching here I found that this question was already asked , but I think
Searching for a way to add this code, after the <head> (or some <link
Searching for a script, which can do show/hide functions without framework. Something like: <span
Searching SO and Google, I've found that there are a few Java HTML parsers
I am attempting to install libxml2 so that I can setup the python bindings

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.