Hi all -

I have a xml file that I am trying to extract data from and create variables to use in a PHP / html form.

I am new to extracting information from xml and creating variables

The XML file is show below and what I would like to learn and understand is how to get the information from each section of the file.

If i can be shown how to create a variable for "enquiry_number" from Section_07 I will complete the rest of the extraction myself as a learning curve to help me understand how this is completed

This is how the xml file looks when called using "view source"

<HPICheck_Query VRM="YP51PVJ" VIN="WF0AXXGCDA1D40899">
−
<Section_07>
<enquiry_number>000001</enquiry_number>
<product_code>HPI11</product_code>
</Section_07>
+
<FirstReg>
<Date>31/01/02</Date>
<vin_vrm_indicator>1</vin_vrm_indicator>
</FirstReg>
+
<Basic>
<Vrm>YP51PVJ</Vrm>
<Fuel>Petrol</Fuel>
<Transmission>5 Speed Manual Petrol</Transmission>
<Make>FORD</Make>
<Model>FOCUS LX</Model>
<Engine_No>1D40899</Engine_No>
<DVLA_Body_Plan_Description>5 Door Hatchback</DVLA_Body_Plan_Description>
<SMMT_Door_Plan_Code>D</SMMT_Door_Plan_Code>
<Engine_Size>01596</Engine_Size>
<DVLA_Body_Plan_Code>14</DVLA_Body_Plan_Code>
<Make_Code>M1</Make_Code>
<fuel_code>1</fuel_code>
<SMMT_Door_Plan_Description>5 Door Hatchback</SMMT_Door_Plan_Description>
<Colour_Code>A</Colour_Code>
<Door_Plan>5 Door Hatchback</Door_Plan>
<Colour>BROWN</Colour>
<Model_Code>867</Model_Code>
<transmission_code>B</transmission_code>
<Vin>WF0AXXGCDA1D40899</Vin>
</Basic>
+
<Additional>
<Prev_Colour/>
<Wheelplan>2 Axle Rigid Body</Wheelplan>
<Wheelplan_code>C</Wheelplan_code>
<Mfr_Year>2002</Mfr_Year>
<Import_Flag>No</Import_Flag>
<original_colour_code/>
<Export_Date/>
<Data_Source/>
<number_of_previous_colours>00</number_of_previous_colours>
<last_previous_colour_code/>
<Weight>0</Weight>
<original_colour_desc/>
<Prev_Colour_Code/>
<Scrap_Date/>
<last_previous_colour_code_desc/>
<Prev_Colour_Date> </Prev_Colour_Date>
</Additional>
+
<Keeper>
<Keepers>000</Keepers>
<previous_keeper_disposal_date>17/06/2005</previous_keeper_disposal_date>
<previous_keeper_acquisition_date>01/02/2002</previous_keeper_acquisition_date>
<Kpr_Change>18/06/2005</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>11040718333549</Session>
</Summary>
+
<Misc_Data>
<Guarantee_Level/>
<Special_Scheme/>
<Date>Thu Apr 7 2011  18:32:45</Date>
</Misc_Data>
</HPICheck_Query>

I have attempted to get the data from the xml using the code below, but this just brings back VRM="YP51PVJ" VIN="WF0AXXGCDA1D40899 from the top of the file.

foreach($HpiCheck_Query->attributes () as $attributes)
	{
	
	echo " ".$attributes->getName()." => ".$attributes." ";
		
	}

any help would be appreciated
Thanks
Lloyd

Please consult the xml the desired result
to generate hand

it is possible to create xsl to xml with this
Always remember to think here are xml user and no php programmer

I usually make only pure xsl xml xquery
and not a programming language
this should not mean the program I can not
just me missing the intricacies of php

Hi thanks for your reply, but I have it working how I thought it should work

<?php foreach ($HpiCheck_Query->Basic->Engine_Size as $Engine_Size) { echo "$Engine_Size "; } ?>
This article has been dead for over six months. Start a new discussion instead.