anavagomez has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl use warnings; use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft ActiveX Data Objects'; use XML::Generator::DBI; use XML::Handler::YAWriter; use XML::DOM; my $doc = XML::DOM::Document->new(); my $xml_pi = $doc->createXMLDecl ('1.0'); my $root = $doc->createElement('DATA'); 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=webtrend1;Port=7 +099;Database=flrdacbkoji.wct;Uid=****;Pwd=*****;AccountId=1;Language= +english;ProfileGuid=KlDwrNbKgm6;SSL=0;"); $objCommand->{"ActiveConnection"} = $objConn; $objCommand->{"CommandText"} = "SELECT * FROM Pages WHERE Titles <> '' + AND URLs IS NOT NULL AND Titles NOT LIKE House TV : 404 Error Page' +AND Titles NOT LIKE '302 Found' AND URLs <> 'http://housetv.com/' AND + URLs <> 'http://housetv.com/index.htm' AND URLs <> 'http://housetv.c +om/wcm/idcplg/' ORDER BY Visits DESC"; $objRecordSet->{"CursorLocation"} = 3; #adUseClient $objRecordSet->{"CursorType"} = 0; #adOpenForwardOnly $objRecordSet->{"LockType"} = 1; #adLockReadOnly; $objRecordSet = $objCommand->Execute(); my ($rec, $col, $val); while (!$objRecordSet->EOF) { $rec = $doc->createElement('RECORD'); $root->appendChild($rec); $col = $doc->createElement('FIELD'); $col->setAttribute ("Name", "Titles"); $rec->appendChild($col); $val = $doc->createTextNode($objRecordSet->Fields("Titles")->val +ue); $col->appendChild($val); $col = $doc->createElement('FIELD'); $col->setAttribute ("Name", "URLs"); $rec->appendChild($col); $val = $doc->createTextNode($objRecordSet->Fields("URLs")->value +); $col->appendChild($val); $col = $doc->createElement('FIELD'); $col->setAttribute ("Name", "Visits"); $rec->appendChild($col); $val = $doc->createTextNode($objRecordSet->Fields("Visits")->val +ue); $col->appendChild($val); $col = $doc->createElement('FIELD'); $col->setAttribute ("Name", "Views"); $rec->appendChild($col); $val = $doc->createTextNode($objRecordSet->Fields("Views")->valu +e); $col->appendChild($val); $objRecordSet->MoveNext(); } print $xml_pi->toString; print $root->toString; $root->printToFile ("C:\\wtxml\data.xml");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to transfer a xml file to server
by dasgar (Priest) on Oct 20, 2010 at 18:51 UTC | |
|
Re: how to transfer a xml file to server
by hbm (Hermit) on Oct 20, 2010 at 18:56 UTC | |
by ikegami (Patriarch) on Oct 20, 2010 at 19:29 UTC | |
|
Re: how to transfer a xml file to server
by Illuminatus (Curate) on Oct 20, 2010 at 20:41 UTC | |
by ikegami (Patriarch) on Oct 20, 2010 at 21:22 UTC |