Hello, I have a perl script that retrieves data from a database and saves the results in a text file.
I need to change this so the database results are saved in an XML file.
I would like to format/ generate the XML tags automatically, but I do not know how to do this, what changes will be necessary on the script.
Any help on how to do this in the code, would be really nice.
This is my current script:
#!/usr/local/bin/perl
use warnings;
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
my $objConn = Win32::OLE->new("ADODB.Connection");
my $objCommand = Win32::OLE->new("ADODB.Command");
my $objRecordSet = Win32::OLE->new("ADODB.Recordset");
$objConn->Open("Driver={Webtrends ODBC Driver};Server=sdfhadgdjlah;Por
+t=7099;Database=flrdacbkoji;Uid=adkljd;Pwd=fadadk;lmam;AccountId=1;La
+nguage=english;ProfileGuid=KlDwrNbKgm6;SSL=0;");
$objCommand->{"ActiveConnection"} = $objConn;
$objCommand->{"CommandText"} = "SELECT * FROM Pages WHERE Titles <> ''
+ AND URLs IS NOT NULL AND Titles NOT LIKE '%404 Error Page%' AND Titl
+es NOT LIKE '%302 Found' AND URLs <> 'http://powerhousetv.com/' AND U
+RLs <> 'http://domain.com/index.htm' AND URLs <> 'http://domain.com/w
+cm/idcplg/' ORDER BY Visits DESC";
$objRecordSet->{"CursorLocation"} = 3; #adUseClient
$objRecordSet->{"CursorType"} = 0; #adOpenForwardOnly
$objRecordSet->{"LockType"} = 1; #adLockReadOnly;
$objRecordSet = $objCommand->Execute();
open OUT, ">output.txt";
while (!$objRecordSet->EOF)
{
print OUT $objRecordSet->Fields("Titles")->value, ", ";
print OUT $objRecordSet->Fields("URLs")->value, ", ";
print OUT $objRecordSet->Fields("Visits")->value, ", ";
print OUT $objRecordSet->Fields("Views")->value, "\n";
$objRecordSet->MoveNext();
}