PHP XML help needed please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

PHP XML help needed please

Post by ianhull »

Hi Guys,

I have the following xml document (currently ony a few records but will be around 50)

Code: Select all

 
<?xml version="1.0" encoding="ISO-8859-1" ?> 
- <properties>
- <property>
  <sale>true</sale> 
  <reference>65384</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>110000</price> 
  <pricelabel>from</pricelabel> 
  <tenure>Leasehold</tenure> 
  <status>Available</status> 
- <address>
  <full>Trinity Quays, High Street, Hull, East Yorkshire, HU1 1EH</full> 
  <name /> 
  <number>60-71</number> 
  <street>Trinity Quays</street> 
  <locality>High Street</locality> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU1 1EH</postcode> 
  <country>GB</country> 
  </address>
  <description /> 
  <location /> 
  <additional /> 
  <feature1 /> 
  <feature2 /> 
  <feature3 /> 
  <feature4 /> 
  <feature5 /> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/245837.jpg</url> 
  <height>370</height> 
  <width>438</width> 
  <position>1</position> 
  <caption>River view</caption> 
  <modified>22-Apr-2008 14:50</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/245839.jpg</url> 
  <height>318</height> 
  <width>495</width> 
  <position>2</position> 
  <caption>Trinity Quay</caption> 
  <modified>22-Apr-2008 14:52</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/245840.jpg</url> 
  <height>379</height> 
  <width>486</width> 
  <position>3</position> 
  <caption>Roadside view</caption> 
  <modified>22-Apr-2008 14:53</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/245841.jpg</url> 
  <height>317</height> 
  <width>400</width> 
  <position>4</position> 
  <caption>Carpark</caption> 
  <modified>22-Apr-2008 14:54</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/245842.jpg</url> 
  <height>359</height> 
  <width>379</width> 
  <position>5</position> 
  <caption>Flood barrier</caption> 
  <modified>22-Apr-2008 14:55</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>true</sale> 
  <reference>66444</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>110000</price> 
  <pricelabel /> 
  <tenure>Leasehold</tenure> 
  <status>Available</status> 
- <address>
  <full>Freedom Quay, The Marina, Hull, HU1 3HA</full> 
  <name /> 
  <number>108</number> 
  <street>Freedom Quay</street> 
  <locality>The Marina</locality> 
  <town>Hull</town> 
  <county /> 
  <postcode>HU1 3HA</postcode> 
  <country>GB</country> 
  </address>
  <description /> 
  <location /> 
  <additional /> 
  <feature1 /> 
  <feature2 /> 
  <feature3 /> 
  <feature4 /> 
  <feature5 /> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
  <photos /> 
  <floorplans /> 
  </property>
- <property>
  <sale>true</sale> 
  <reference>66446</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>120000</price> 
  <pricelabel /> 
  <tenure>Leasehold</tenure> 
  <status>Available</status> 
- <address>
  <full>Freedom Quay, The Marina, Hull, East Yorkshire, HU1 3HA</full> 
  <name /> 
  <number>203</number> 
  <street>Freedom Quay</street> 
  <locality>The Marina</locality> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU1 3HA</postcode> 
  <country>GB</country> 
  </address>
  <description /> 
  <location /> 
  <additional /> 
  <feature1 /> 
  <feature2 /> 
  <feature3 /> 
  <feature4 /> 
  <feature5 /> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
  <photos /> 
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>67409</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>400</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Silver Street, Old Town, Hull, East Yorkshire, HU1 1JG</full> 
  <name>Flat 4</name> 
  <number>27a-28</number> 
  <street>Silver Street</street> 
  <locality>Old Town</locality> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU1 1JG</postcode> 
  <country>GB</country> 
  </address>
  <description>A very well thought out conversion in this listed building in a popular area of the 'old town'.</description> 
  <location>Ideally located in the cnetre of Hull, close to all that Hull has to offer. Easy access to the rail networks with regular trains to the capital.</location> 
  <additional>This property in offered in very nice order and the bright and airy living room with large windows and high ceilings is a pleasure to be in! Watch the world pass by............</additional> 
  <feature1>1 bedroom apartment</feature1> 
  <feature2>bright and airy living room</feature2> 
  <feature3>modern kitchen area</feature3> 
  <feature4>bathroom with shower cubicle</feature4> 
  <feature5>Lovely high ceilings and large windows</feature5> 
  <feature6>Well maintained communal area</feature6> 
  <feature7>City centre parking permit available</feature7> 
  <feature8>Council Tax Band A</feature8> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255496.jpg</url> 
  <height>370</height> 
  <width>490</width> 
  <position>1</position> 
  <caption>Front</caption> 
  <modified>22-May-2008 10:41</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255497.jpg</url> 
  <height>370</height> 
  <width>490</width> 
  <position>2</position> 
  <caption>Living room</caption> 
  <modified>22-May-2008 10:42</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255498.jpg</url> 
  <height>370</height> 
  <width>490</width> 
  <position>3</position> 
  <caption>kitchen</caption> 
  <modified>22-May-2008 10:42</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>66245</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>2</bedrooms> 
  <price>450</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Robinson Row, Hull, East Yorkshire, HU1 2RR</full> 
  <name>Flat 4</name> 
  <number>12-14</number> 
  <street>Robinson Row</street> 
  <locality /> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU1 2RR</postcode> 
  <country>GB</country> 
  </address>
  <description>A recently converted building split into four apartments on two floors situated in 'The Old Town'.</description> 
  <location>Ideal location within the city centre close to shops bars and local amenities</location> 
  <additional /> 
  <feature1>2 bedrooms</feature1> 
  <feature2>large living kitchen</feature2> 
  <feature3>bathroom bath and shower over</feature3> 
  <feature4>oven, hob, hood and fridge</feature4> 
  <feature5>washing machine</feature5> 
  <feature6>carpets and blinds throughout</feature6> 
  <feature7>fire alarm throughout building</feature7> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/249795.jpg</url> 
  <height>308</height> 
  <width>408</width> 
  <position>1</position> 
  <caption>Robinson Row</caption> 
  <modified>06-May-2008 12:45</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>62834</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>525</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Queens Court, Queens Gardens, Hull, HU1 3DR</full> 
  <name>51</name> 
  <number /> 
  <street>Queens Court</street> 
  <locality>Queens Gardens</locality> 
  <town>Hull</town> 
  <county /> 
  <postcode>HU1 3DR</postcode> 
  <country>GB</country> 
  </address>
  <description>A good sized 1 bedroom apartment situated within this prestigious development on Queens Gardens.<br />The property benefits from an allocated parking space.</description> 
  <location /> 
  <additional /> 
  <feature1>1 bed second floor apartment</feature1> 
  <feature2>modern kitchen</feature2> 
  <feature3>integrated appliances</feature3> 
  <feature4 /> 
  <feature5 /> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/249788.jpg</url> 
  <height>212</height> 
  <width>320</width> 
  <position>1</position> 
  <caption>Queens Court</caption> 
  <modified>06-May-2008 12:22</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/252571.jpg</url> 
  <height>333</height> 
  <width>441</width> 
  <position>2</position> 
  <caption>Kitchen</caption> 
  <modified>13-May-2008 18:13</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/252574.jpg</url> 
  <height>308</height> 
  <width>408</width> 
  <position>3</position> 
  <caption>living room</caption> 
  <modified>13-May-2008 18:14</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>67249</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>525</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Baker Street, Hull, East Yorkshire, HU2 8HE</full> 
  <name>27</name> 
  <number /> 
  <street>Baker Street</street> 
  <locality /> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU2 8HE</postcode> 
  <country>GB</country> 
  </address>
  <description>A very well presented 1 bedroomed apartment situated in this prestigious area within Hull City Centre</description> 
  <location /> 
  <additional /> 
  <feature1>Modern 1 bedroom ground floor flat</feature1> 
  <feature2>Living room</feature2> 
  <feature3>Modern fitted kitchen</feature3> 
  <feature4>Bathroom</feature4> 
  <feature5>Parking space allocated with permit</feature5> 
  <feature6>Communal sky dish</feature6> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/254346.jpg</url> 
  <height>387</height> 
  <width>516</width> 
  <position>1</position> 
  <caption>Kitchen</caption> 
  <modified>19-May-2008 17:12</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/254347.jpg</url> 
  <height>387</height> 
  <width>516</width> 
  <position>2</position> 
  <caption>Living room</caption> 
  <modified>19-May-2008 17:12</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/254352.jpg</url> 
  <height>406</height> 
  <width>542</width> 
  <position>3</position> 
  <caption>Bathroom</caption> 
  <modified>19-May-2008 17:13</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>67373</reference> 
  <type>Flat</type> 
  <area>West Hull</area> 
  <bedrooms>3</bedrooms> 
  <price>525</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Pearson Park, Beverley Road, Hull, East Yorkshire, HU5 4TG</full> 
  <name>Flat 4</name> 
  <number>7</number> 
  <street>Pearson Park</street> 
  <locality>Beverley Road</locality> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU5 4TG</postcode> 
  <country>GB</country> 
  </address>
  <description>A good sized flat situated in this large converted building overlooking Pearson Park.</description> 
  <location>Close to every amenity and facility you could wish for with easy access to the city centre.</location> 
  <additional /> 
  <feature1>3 bedrooms</feature1> 
  <feature2>bathroom</feature2> 
  <feature3>living room</feature3> 
  <feature4>kitchen</feature4> 
  <feature5>overlooking the park</feature5> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
  <photos /> 
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>67378</reference> 
  <type>Terraced</type> 
  <area>North Hull</area> 
  <bedrooms>2</bedrooms> 
  <price>525</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Welwyn Park Avenue, Beverley Road, Hull, East Yorkshire, HU6 7DL</full> 
  <name /> 
  <number>132</number> 
  <street>Welwyn Park Avenue</street> 
  <locality>Beverley Road</locality> 
  <town>Hull</town> 
  <county>East Yorkshire</county> 
  <postcode>HU6 7DL</postcode> 
  <country>GB</country> 
  </address>
  <description>A 2 bed terraced house in very nice order.</description> 
  <location>This property is ideally positioned for travel into the city centre and close to all amenities and facilities.</location> 
  <additional /> 
  <feature1>2 bedrooms</feature1> 
  <feature2>living room</feature2> 
  <feature3>kitchen</feature3> 
  <feature4>bathroom</feature4> 
  <feature5>gardens front and rear</feature5> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255604.jpg</url> 
  <height>369</height> 
  <width>492</width> 
  <position>1</position> 
  <caption>living room</caption> 
  <modified>22-May-2008 15:30</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255605.jpg</url> 
  <height>346</height> 
  <width>461</width> 
  <position>2</position> 
  <caption>dining area</caption> 
  <modified>22-May-2008 15:31</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255606.jpg</url> 
  <height>461</height> 
  <width>615</width> 
  <position>3</position> 
  <caption>kitchen</caption> 
  <modified>22-May-2008 15:31</modified> 
  </photo>
- <photo>
  <url>http://www.lime-property.co.uk/photos/255608.jpg</url> 
  <height>346</height> 
  <width>461</width> 
  <position>4</position> 
  <caption>garden</caption> 
  <modified>22-May-2008 15:31</modified> 
  </photo>
  </photos>
  <floorplans /> 
  </property>
- <property>
  <sale>false</sale> 
  <reference>66448</reference> 
  <type>Flat</type> 
  <area>Hull Centre</area> 
  <bedrooms>1</bedrooms> 
  <price>550</price> 
  <pricelabel /> 
  <tenure>Assured Shorthold Tenancy</tenure> 
  <status>Available</status> 
- <address>
  <full>Freedom Quay, The Marina, Hull, HU1 3HA</full> 
  <name /> 
  <number>108</number> 
  <street>Freedom Quay</street> 
  <locality>The Marina</locality> 
  <town>Hull</town> 
  <county /> 
  <postcode>HU1 3HA</postcode> 
  <country>GB</country> 
  </address>
  <description>A brand new complex of apartments, offices and retail outlets.</description> 
  <location /> 
  <additional /> 
  <feature1>Brand new building</feature1> 
  <feature2>1 bedroom</feature2> 
  <feature3 /> 
  <feature4 /> 
  <feature5 /> 
  <feature6 /> 
  <feature7 /> 
  <feature8 /> 
  <rooms /> 
- <photos>
- <photo>
  <url>http://www.lime-property.co.uk/photos/250976.jpg</url> 
  <height>204</height> 
  <width>215</width> 
  <position>1</position> 
  <caption>Freedom Quay</caption> 
  <modified>08-May-2008 15:25</modified> 
  </photo>
  </photos>
- <floorplans>
- <floorplan>
  <url>http://www.lime-property.co.uk/floorplans/2471.png</url> 
  <height>218</height> 
  <width>434</width> 
  <position>1</position> 
  <caption>TYPE H 1ST FLOOR</caption> 
  <modified>20-May-2008 12:09</modified> 
  </floorplan>
  </floorplans>
  </property>
  </properties>
 
I need to be able to search this document for a price and location and do some stuff with it, for example, if a price matches a search price and the location matches the location i need to return all the property details.

One other way I could do it is if: big if, I could get all these properties into seperate arrays (php arrays) I could then insert them into my database and then I can work the rest out from there.

Any ideas? solutions?

Thanks in advance.
Post Reply