PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.

How to tidy XML file

Below is the simple perl code that will clean up the xml file. You can use XML::Tidy library.

use strict;
use XML::Tidy;

use Win32;


if ($ARGV[0] eq "") {
print "XML file is missing\n\t xmltidy.exe \"File.xml\"\n"
}else
{

if ($ARGV[0]!~ /.xml$/){print "XML file is missing\n\t xmltidy.exe \"File.xml\"\n";exit;}
my $xml=$ARGV[0];
if (!(-f $ARGV[0])) {$xml=Win32::GetCwd().'\\'.$ARGV[0]} ;
# create new XML::Tidy object from MainFile.xml
my $tidy_obj = XML::Tidy->new('filename' => $xml);
# Tidy up the indenting
$tidy_obj->tidy();
# Write out changes back to MainFile.xml
$tidy_obj->write();

}

No comments:

WebProNews Feed

eWeek - RSS Feeds

HowtoForge - Howtos and Tutorials

The Register

PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.