Jump to content

XML newbie almost there!


awebbdesign

Recommended Posts

I have the following xml file...

 

 

<property id="21179035" propertyid="111290" system="A" firmid="11548" branchid="1" database="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://webservices.vebra.com/export/xsd/v1/exportapi.xsd">

<reference>

<agents>11290</agents>

</reference>

<address>

<name>16</name>

<street>Bardsey Close</street>

<locality>Wootton Bassett</locality>

<town>Swindon</town>

<county>Wilts</county>

<postcode>SN4 8NA</postcode>

<custom_location>West of Swindon</custom_location>

<display>Wootton Bassett, Swindon</display>

</address>

<price qualifier="" currency="GBP">107750</price>

<rm_qualifier>0</rm_qualifier>

<available>01/01/1900</available>

<uploaded>04/08/2010</uploaded>

<longitude>-1.886723</longitude>

<latitude>51.54373</latitude>

<easting>407855</easting>

<northing>182820</northing>

<web_status>1</web_status>

<custom_status />

<comm_rent />

<premium />

<service_charge />

<rateable_value />

<type>Maisonette</type>

<type />

<furnished>3</furnished>

<rm_type>0</rm_type>

<let_bond>0</let_bond>

<rm_let_type_id>0</rm_let_type_id>

<bedrooms>2</bedrooms>

<receptions>0</receptions>

<bathrooms>1</bathrooms>

<userfield1 />

<userfield2>0</userfield2>

 

<area measure="metric" unit="sqm">

<min>0</min>

<max>0</max>

</area>

<area measure="imperial" unit="sqft">

<min>0</min>

<max>0</max>

</area>

<description>Primary are pleased to offer this two bedroom first floor maisonette in Wootton Bassett. The accommodation comprises of private entrance hall, lounge, kitchen, two bedrooms and bathroom. The property also benefits from uPVC double glazing, central heating and two allocated parking spaces. No onward chain.

</description>

<hip>

<energy_performance>

<energy_efficiency>

<current>67</current>

<potential>77</potential>

</energy_efficiency>

<environmental_impact>

<current>67</current>

<potential>80</potential>

</environmental_impact>

</energy_performance>

</hip>

<paragraphs>

<paragraph id="1" type="0">

<name>DESCRIPTION</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Primary are pleased to offer this two bedroom first floor maisonette in Wootton Bassett. The accommodation comprises of private entrance hall, lounge, kitchen, two bedrooms and bathroom. The property also benefits from uPVC double glazing, central heating and two allocated parking spaces. No onward chain.

</text>

</paragraph>

<paragraph id="2" type="0">

<name>PRIVATE ENTRANCE PORCH</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Storage cupboard.</text>

</paragraph>

<paragraph id="3" type="0">

<name>PRIVATE ENTRANCE HALL</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Stairs leading to first floor. Radiator.</text>

</paragraph>

<paragraph id="4" type="0">

<name>FIRST FLOOR</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Landing: Loft access (part boarded), built in storage cupboard with hanging rail, airing cupboard. Doors leading to lounge, bathroom and both bedrooms.</text>

</paragraph>

<paragraph id="5" type="0">

<name>LIVING ROOM</name>

<file ref="1" />

<dimensions>

<metric />

<imperial />

<mixed>5.05m(16'7'') x 3.43m(11'3'')</mixed>

</dimensions>

<text>uPVC double glazed window to front elevation. TV point. Telephone point. Radiator. Door leading to:</text>

</paragraph>

<paragraph id="6" type="0">

<name>KITCHEN</name>

<file ref="2" />

<dimensions>

<metric />

<imperial />

<mixed>2.57m(8'5'') x 2.54m(8'4'')</mixed>

</dimensions>

<text>uPVC double glzed window to rear elevation. Wall and base units with rolled edge work surfaces over. Wall mounted central heating boiler and thermostat. Space for fridge freezer, oven and washer drier. Tiled splashbacks.</text>

</paragraph>

<paragraph id="7" type="0">

<name>BEDROOM ONE</name>

<file ref="3" />

<dimensions>

<metric />

<imperial />

<mixed>3.76m(12'4'') x 3.05m(10'0'')</mixed>

</dimensions>

<text>uPVC double glazed window to front elevation. Built in double wardrobe. Telephone extension. Radiator.</text>

</paragraph>

<paragraph id="8" type="0">

<name>BEDROOM TWO</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed>3.71m(12'2'') x 2.26m(7'5'')</mixed>

</dimensions>

<text>uPVC double glazed window to rear elevation. Radiator.</text>

</paragraph>

<paragraph id="9" type="0">

<name>BATHROOM</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Obscure uPVC double glazed window to rear elevation. White suite comprising of panel bath with shower over, pedestal hand wash basin and low level WC. Radiator.</text>

</paragraph>

<paragraph id="10" type="0">

<name>VIEWING</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Strictly via our Swindon office telephone (01793) 641641, out of office hours Dawn Graham 07887763163.</text>

</paragraph>

<paragraph id="11" type="0">

<name>MORTGAGES</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>If you would like independent mortgage advice please call Primary Mortgage Centre on (01793) 616617. Home visits available.</text>

</paragraph>

<paragraph id="12" type="0">

<name>MONEY LAUNDERING</name>

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>Intending purchasers will be asked to produce identification documentation at a later stage and we would ask for your co-operation in order that there will be no delay in agreeing the sale.</text>

</paragraph>

<paragraph id="13" type="2">

<name />

<file />

<dimensions>

<metric />

<imperial />

<mixed />

</dimensions>

<text>This footer paragraph is an example only and should not be relied upon as complying with current legislation.  These particulars, whilst believed to be accurate are set out as a general outline only for guidance and do not constitute any part of an offer or contract. Intending purchasers should not rely on them as statements of representation of fact, but must satisfy themselves by inspection or otherwise as to their accuracy. No person in this firms employment has the authority to make or give any representation or warranty in respect of the property.<br/></text>

</paragraph>

</paragraphs>

 

<bullets>

<bullet id="1">First Floor Maisonette</bullet>

<bullet id="2">Two Bedrooms</bullet>

<bullet id="3">Lounge</bullet>

<bullet id="4">Kitchen</bullet>

<bullet id="5">Private Entrance</bullet>

<bullet id="6">Allocated Parking</bullet>

<bullet id="7">Good Location</bullet>

<bullet id="8">No Onward Chain</bullet>

</bullets>

 

<files>

<file id="0" type="0">

<name />

<url>http://images.vebra.com/images/1548/001/type1/bardse~1.jpg</url>

<updated>30/08/2011 17:03:00</updated>

</file>

<file id="1" type="0">

<name>LIVING ROOM</name>

<url>http://images.vebra.com/images/1548/001/type1/bardse~2.jpg</url>

<updated>30/08/2011 17:03:00</updated>

</file>

<file id="2" type="0">

<name>KITCHEN</name>

<url>http://images.vebra.com/images/1548/001/type1/bardse~3.jpg</url>

<updated>30/08/2011 17:03:00</updated>

</file>

<file id="3" type="0">

<name>BEDROOM ONE</name>

<url>http://images.vebra.com/images/1548/001/type1/bardse~4.jpg</url>

<updated>30/08/2011 17:03:00</updated>

</file>

<file id="4" type="9">

<name>Energy efficiency chart</name>

<url>http://images.vebra.com/home/hip/EE_0275_067_077.png</url>

</file>

<file id="5" type="9">

<name>Environmental impact chart</name>

<url>http://images.vebra.com/home/hip/EI_0275_067_080.png</url>

</file>

</files>

 

</property>

 

I have the following code...

 

# address - basic info

if(is_object($xml->address)) {

foreach($xml->address as $address) {

//print_r($property);

$name = $address->name;

$street = $address->street;

$locality = $address->locality;

$town = $address->town;

$county = $address->county;

$postcode = $address->postcode;

$custom_location = $address->custom_location;

$display = $address->display;

 

$insertS = "INSERT INTO $tablec (pal, afield, bfield, cfield, dfield, efield, ffield, hfield, ifield, jfield) VALUES

(110, '$bD->afield', '$name', '$street', '$locality', '$town', '$county', '$postcode', '$custom_location', '$display')";

$insertQ = mysql_query($insertS);

$iid = mysql_insert_id();

}

}

 

# property - basic info

if(is_object($xml)) {

foreach($xml as $property) {

//print_r($property);

$long = $property->longitude;

$lat = $property->latitude;

$type = $property->type;

$furnished = $property->furnished;

$bedrooms = $property->bedrooms;

$bathrooms = $property->bathrooms;

$description = $property->description;

 

$updateS = "UPDATE $tablec SET

kfield = '$long',

lfield = '$lat',

mfield = '$type',

nfield = '$furnished',

ofield = '$bedrooms',

pfield = '$bathrooms',

atext = '$description'

WHERE pal = 110

AND id = $iid";

$updateQ = mysql_query($updateS);

 

print "<p>$updateS</p>";

 

}

}

 

The first bit is working fine (# address - basic info) and I am able to get the information out, however the longitude and

latitude bit I'm struggling with (# property - basic info)

 

Any help would be much appreciated.

Link to comment
Share on other sites

Please wrap your XML in [ code ] tag.

Also are you getting any errors when trying to get the lat and long?

Are these values fine?

$furnished = $property->furnished;
         $bedrooms = $property->bedrooms;
         $bathrooms = $property->bathrooms;
         $description = $property->description;

Link to comment
Share on other sites

The values you've mentioned don't work. I suspect it's this bit...

 

<code>

if(is_object($xml)) {

foreach($xml as $property) {

//print_r($property);

$long = $property->longitude;

$lat = $property->latitude;

$type = $property->type;

$furnished = $property->furnished;

$bedrooms = $property->bedrooms;

$bathrooms = $property->bathrooms;

$description = $property->description;

 

$updateS = "UPDATE $tablec SET

kfield = '$long',

lfield = '$lat',

mfield = '$type',

nfield = '$furnished',

ofield = '$bedrooms',

pfield = '$bathrooms',

atext = '$description'

WHERE pal = 110

AND id = $iid";

$updateQ = mysql_query($updateS);

 

print "<p>Furnished: $furnished</p>";

 

}

}

</code>

 

Either...

if(is_object($xml)) {

 

Or.. foreach($xml as $property) {

 

needs changing; I'm just not sure, any ideas?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.