Is there a stylesheet or Windows commandline tool

2020-02-10 15:11发布

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.

7条回答
虎瘦雄心在
2楼-- · 2020-02-10 15:42

XML Notepad 2007 can do so manually ... let me see if it can be scripted.

Nope ... it can launch it like so:

XmlNotepad.exe a.xml

The rest is just clicking the save button. Power Shell, other tools can automate that.

查看更多
登录 后发表回答