Tapatalk

Formatting XML

Formatting XML

1
NewbieNewbie
1

    Apr 14, 2005#1

    Hi,

    Can UltraEdit format an XML document?

    For example: <TAG1><SUB>HELLO</SUB></TAG1> would become

    Code: Select all

    <TAG1>
      <SUB>HELLO</SUB>
    </TAG1>
    I am the registered user of UltraEdit 9 and was wondering if there is a way to do above.

    Thanks in advance.

    1
    NewbieNewbie
    1

      Apr 15, 2005#2

      You can use Tidy for formatting. I have following Perl script assigned to tools, but guess you can also use bat or wsh :

      Command line: perl -w C:\bin\xmlformat.pl "%f"

      C:\bin\xmlformat.pl

      Code: Select all

      #!perl -w
      
      # Name: xmlformat.pl
      #
      # Use tidy to change input file and make bak
      # Usage: xmlformat.pl xmlfile.xml
      
      use strict;
      use File::Copy;
      
      die "No args...\n"
       unless 0==$#ARGV;
      
      my $xmlfile = shift;
      die "Could not copy $xmlfile. $!\n"
       unless copy($xmlfile, "$xmlfile.bak");
      
      my @args = ('C:\\bin\\tidy.exe', '-m', '-xml', '-q', '-i', $xmlfile);
      system(@args) == 0 or die "system @args failed: $?"
      
      Regards,
      vel

      2
      NewbieNewbie
      2

        Aug 01, 2005#3

        vel, thank you for the hint to Tidy. As a non Perl programmer I'm now using an UltraEdit Tool configuration with the command line

        Code: Select all

        cmd /c if /I "%E"==".XML" (E:\schlereth\tools\tidy\tidy-050522-exe\tidy.exe -m -xml -i "%F") else (echo NO XML File)
        and

        Command Output (DOS Commands) to List Box, Capture Output.

        1
        NewbieNewbie
        1

          Aug 29, 2011#4

          Hi,

          UltraEdit v17 does it (maybe previous releases too):
          1. Select the desired text,
          2. in the main menu, select Paragraph Formatting + ReIndent Selection, the result is here as the result of an XML beautifuller output
          Regards

          Bonjour,

          UltraEdit v17 le fait (peut être d'autres versions précédentes également):
          1. Sélectionner le texte désiré,
          2. dans le menu principal, sélectionner Formatage du paragraphe + Indenter de nouveau la sélection, le résultat est là, identique à la sortie d'un embellisseur XML
          Cordialement

          901
          MasterMaster
          901

            Sep 01, 2011#5

            Wow, you really dug up an old post to respond to. The easiest way to handle the original post in the current version of UltraEdit is with the drop-down menu option:

            Format -> XML Convert to CR/LFs

            1
            NewbieNewbie
            1

              Nov 11, 2020#6

              bulgrien, 9 years later your post helped me out.  Thanks!  --Joe

              6,685587
              Grand MasterGrand Master
              6,685587

                Nov 12, 2020#7

                The command XML Convert to CR/LFs in menu Format was introduced with UltraEdit for Windows v11.20 and UEStudio v5.10 for files syntax highlighted as XML files. This command became available for all files, regardless of file extension and syntax highlighting, with UltraEdit for Windows v17.10 and UEStudio v11.10.

                The command XML Convert to CR/LFs in traditional menu Format was replaced by Reformat XML in submenu XML with UltraEdit for Windows v27.00 and UEStudio v20.00 which additionally introduced the command Compress XML. The commands are in menu Coding in submenu XML on using contemporary menus. In ribbon mode the commands are listed in popup menu opened on clicking on ribbon tab Coding in group Formatting on down arrow of item XML.
                Best regards from an UC/UE/UES for Windows user from Austria