I am trying to write a script that will read an XML file returned from a server when a Registration Number is sent.
I have saved a copy of the file that is returned so i can initally find out the structure of the file using the dumper output method but the script seems to stop when it gets to the XMLin part.
once i have managed to get the script to read the XML file and display the output i will change it to read the XML direct from the source. Any hint in how to do this will be appreciated.
here is the script i have got, The actual URL where the file originates it hashed out.
#!/usr/bin/perl
# use module
use XML::Simple;
use Data::Dumper;
print "Content-type: text/html\n\n";
# create object
$xml = XML::Simple->new();
print "Object Created<br>";
# read XML file
#$fh = IO::File->new('http://www.q.hpixml.com/servlet/HpiGate1_0?forwa
+rd=YES&efxid=0503506&password=testing&initials=mk&function=SEARCH&vrm
+=fp08rou&XML=YES&product=HPI11&devicetype=XM');
$fh = "d:\\inetpub\\wwwroot\\cgi-bin\\classads\\testxmlfile.xml";
print "$fh<br>";
$data = $xml->XMLin('testxmlfile.xml');
print "File read<br>";
# print output
print Dumper($data);
print "done!!";
here is the XML that is sent from the server,
<?xml version="1.0"?>
<HPICheck_Query VRM="FP08ROU" VIN="ZAR93700003421796">
<Section_07>
<enquiry_number>000001</enquiry_number>
<product_code>HPI11</product_code>
</Section_07>
<FirstReg>
<Date>16/05/08</Date>
<vin_vrm_indicator>1</vin_vrm_indicator>
</FirstReg>
<Basic>
<Vrm>FP08ROU</Vrm>
<Fuel>Diesel</Fuel>
<Transmission>5 Speed Manual Diesel</Transmission>
<Make><![CDATA[ALFA ROMEO]]></Make>
<Model><![CDATA[147 COLLEZIONE JTDM]]></Model>
<Engine_No>5942518</Engine_No>
<DVLA_Body_Plan_Description>5 Door Hatchback</DVLA_Body_Plan_Descripti
+on>
<SMMT_Door_Plan_Code>D</SMMT_Door_Plan_Code>
<Engine_Size>01910</Engine_Size>
<DVLA_Body_Plan_Code>14</DVLA_Body_Plan_Code>
<Make_Code>N0</Make_Code>
<fuel_code>2</fuel_code>
<SMMT_Door_Plan_Description>5 Door Hatchback</SMMT_Door_Plan_Descripti
+on>
<Colour_Code>N</Colour_Code>
<Door_Plan>5 Door Hatchback</Door_Plan>
<Colour>WHITE</Colour>
<Model_Code>422</Model_Code>
<transmission_code>F</transmission_code>
<Vin>ZAR93700003421796</Vin>
</Basic>
<Additional>
<Prev_Colour></Prev_Colour>
<Wheelplan>2 Axle Rigid Body</Wheelplan>
<Wheelplan_code>C</Wheelplan_code>
<Mfr_Year>2008</Mfr_Year>
<Import_Flag>No</Import_Flag>
<original_colour_code></original_colour_code>
<Export_Date></Export_Date>
<Data_Source></Data_Source>
<number_of_previous_colours>00</number_of_previous_colours>
<last_previous_colour_code></last_previous_colour_code>
<Weight>0</Weight>
<original_colour_desc></original_colour_desc>
<Prev_Colour_Code></Prev_Colour_Code>
<Scrap_Date></Scrap_Date>
<last_previous_colour_code_desc></last_previous_colour_code_desc>
<Prev_Colour_Date> </Prev_Colour_Date>
</Additional>
<Keeper>
<Keepers>000</Keepers>
<previous_keeper_disposal_date> </previous_keeper_disposal_date>
<previous_keeper_acquisition_date> </previous_keeper_acquisition_date>
<Kpr_Change>16/05/2008</Kpr_Change>
</Keeper>
<Summary>
<Veh_Regd>Recorded</Veh_Regd>
<Plate_Xfr>Not Recorded</Plate_Xfr>
<Sec_Watch>0</Sec_Watch>
<Stolen>0</Stolen>
<Finance>0</Finance>
<Cond_Damgd>0</Cond_Damgd>
<Cond_Theft>0</Cond_Theft>
<Cond_Hist>0</Cond_Hist>
<VIN_Match>Not Matched</VIN_Match>
<Session>10120609455564</Session>
</Summary>
<Misc_Data>
<Guarantee_Level></Guarantee_Level>
<Special_Scheme></Special_Scheme>
<Date>Mon Dec 6 2010 09:45:48</Date>
</Misc_Data>
</HPICheck_Query>
NB: The details in the XML file are made up.
Once i have found the structure of the XML I will generate a page displaying the details of the vehicle serached for.
Thanks for any help.
Michael