Page 1 of 1

XML Feed through a Parser - what does that mean, and how?

Posted: Tue Mar 29, 2011 1:47 pm
by simonmlewis
Hi.
I've been given the code below, to add the data into our MySQL database, and have been told this... and I quote:
As part of the XML parsing you will need to write code to match the feeds to yours, when you run the parser and then import all the data you will then import into your matched fields.
This is the code - or a portion of it:
[text]- <root>
<virtualpropertyshop feed_version="1.01" />
- <property>
- <!--
ONE FOR EVERY PROPERTY IN DATABASE
-->
<id>120019</id>
- <!--
ALWAYS PRESENT: 1 to 2,147,483,647 (long integer)
-->
<date>2005-04-18 12:54:16</date>
- <!--
ALWAYS PRESENT
-->
<ref>CBH025</ref>
- <!--
ALWAYS PRESENT: 0 to 15 chars
-->
<price>190</price>
- <!--
ALWAYS PRESENT: 0 to 922,337,203,685,477.5807 (decimal); 0=price upon
application; if holiday let then this is the minimum price, full holiday let
pricing may be provided below
-->
<price_freq>sale</price_freq>
- <!--
ALWAYS PRESENT: sale=sale, month=long-term let, week=holiday let
-->
<currency>EUR</currency>
- <!--
ALWAYS PRESENT: 3 char standard currency code
-->
- <type>
<en>Apartment</en>
- <!--
ALWAYS AT LEAST ONE LANGUAGE PRESENT: 0 to 255 chars
-->
<en>Piso</en>
- <!--
OPTIONAL: more than one language
-->
</type>
<town>Torrevieja</town>
- <!--
ALWAYS PRESENT: 0 to 100 chars
-->
<province>Alicante</province>
- <!--
ALWAYS PRESENT: 0 to 100 chars
-->
<location_detail>Zeniamar, Playa Flamenca, Orihuela Costa</location_detail>
- <!--
ALWAYS PRESENT: 0 to 50 chars
-->
<built_size>200</built_size>
- <!--
OPTIONAL: 0 to 2,147,483,647 (long integer) in square metres
-->
<land_size>500</land_size>
- <!--
OPTIONAL: 0 to 2,147,483,647 (long integer) in square metres
-->
<constructed_year>1994</constructed_year>
- <!--
OPTIONAL (integer)
-->
<location_of_property>City</location_of_property>
- <!--
OPTIONAL: 0 to 100 chars
-->
<approach_to_property>Busy Road</approach_to_property>
- <!--
OPTIONAL: 0 to 100 chars
-->
<turnover>250000</turnover>
- <!--
OPTIONAL: 0 to 2,147,483,647 (long integer) commercial properties only
-->
<date_available>2005-06-01 00:00:00</date_available>
- <!--
OPTIONAL: long term rental properties only
-->
<number_of_rooms>NumberOfRooms</number_of_rooms>
- <!--
OPTIONAL: 0 to 255 (byte)
-->
<sleeps>Sleeps</sleeps>
- <!--
OPTIONAL: 0 to 255 (byte)
-->
<beds>2</beds>
- <!--
OPTIONAL: 0 to 255 (byte)
-->
<salons>1</salons>
- <!--
[/text]

What is a "parser" and how do I use it to 'parse' this data thru it to get it into the database, that has fields completely different from these?

Simon