Hi, I am using SimpleXML to work with a database file that i have. The XML data is like so: - <Property> <ID>14209</ID> <Partner_Id>15</Partner_Id> - <Name> - <![CDATA[ ]]> </Name> - <Reference> - <![CDATA[ NOBR15 ]]> </Reference> <Country>Portugal</Country> - <Region> - <![CDATA[ Madeira ]]> </Region> - <Location1> - <![CDATA[ Funchal ]]> </Location1> - <Location2> - <![CDATA[ ]]> </Location2> <Type>Villa</Type> <New_Development>0</New_Development> <Leaseback>0</Leaseback> <Investment>N</Investment> <Price>404750.00</Price> <Currency>GBP</Currency> <Bedrooms>5</Bedrooms> <Delivery_Date /> - <Short_Description> - <![CDATA[ ]]> </Short_Description> - <Long_Description> - <![CDATA[ A TRUE RURAL RETREAT IN A TRANQUIL SETTING AMONGST LUSH VEGETATION ! Split level Quinta /Vila - on the Funchal Border - only 12km away from Funchal and 600m above sea level with breathtaking sea and mountainviews ! Only 4 years old ! Large 7070 m2 grounds Building rights for at least another dwelling to be built on the land - eg. granny cottage or another residential home. Type: Residential Style: 2 Story Split "Modern Upmarket Vila Design" Bedrooms: 4 "WITH BUILT IN CUPBOARDS" Bathrooms: 3 "MAIN EN-SUITE" Garage: Triple "LOADS OF EXTRA PARKING" Basement: No Size: 495 m² Lot Type: Rectangular Lot Size: 7070 m² n/a "WITH PERMISSION FOR BUILDING ANOTHER HOME ON STAND" Has Suite: Yes Year Built: 2000 "AS NEW" Taxes: €0.00 EUR Condo Fees: €0.00 EUR ]]> </Long_Description> - <Small_Image_URL> - <![CDATA[ http://www.nobregarealty.com/Shared/Cache/Listing/114108/Photo/7-Gallery.img?_Version=632208272672200000 ]]> </Small_Image_URL> - <Large_Image_URL> - <![CDATA[ http://www.nobregarealty.com/Shared/Cache/Listing/114108/Photo/7-Gallery.img?_Version=632208272672200000 ]]> </Large_Image_URL> <Extra_Images /> - <Currencies> - <Currency> <Name>EUR</Name> <Price>599097.10</Price> </Currency> - <Currency> <Name>GBP</Name> <Price>404750.00</Price> </Currency> - <Currency> <Name>USD</Name> <Price>754848.94</Price> </Currency> </Currencies> </Property> Code (markup): For a simple test i have tried: <?php $xml = simplexml_load_file('database/db.xml'); foreach ($xml->widget as $widget) { echo "<div class='widget'>"; echo "<span class='Country'>" . $widget->Location2 . "</span>"; echo "</div>"; } ?> Code (markup): But this does not seem to bring anything back. How would i go about first showing the data and also selecting certain data e.g. using POST values to select only certain results. Any ideas? Cheers, Adam
It's hard to say why $xml->widget won't work without the whole XML file. Or at least its structure. As for the selecting, you can simply do: if ($widget->Location2 == $_POST['location2']) { // echo data } PHP: In the loop.