adamjblakey Posted September 6, 2007 Share Posted September 6, 2007 Hi, I need to be able to search an XML database but unsure on how to do so. Example data from the database is: - <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> So what i need to do is be able to search each field like an advanced search. I have only ever worked with SQL before so unsure on how to do this? Adam Quote Link to comment Share on other sites More sharing options...
Barand Posted September 6, 2007 Share Posted September 6, 2007 if you use simplexml it will create a multi-dimensional array which you can then search. Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted September 10, 2007 Author Share Posted September 10, 2007 I am using php4 not 5 Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted September 10, 2007 Author Share Posted September 10, 2007 I have found a class that i can work with here: http://www.shop24-7.info/32-0-simplexml-alternative-php4.html But what i need to know is how to work with this bit here: $xml_parser = new sxml; $src=implode ('', file ($url)); $xml_parser->parse($src); $xml=$xml_parser->data; print_r($xml); I need to know how to add a condition to this e.g. print $XML where $_POST[country] = country Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2007 Share Posted September 10, 2007 see http://www.phpfreaks.com/forums/index.php/topic,156954.msg682543.html#msg682543 Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted September 10, 2007 Author Share Posted September 10, 2007 Thank your for that link, it appears though that it also uses simple XML also. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2007 Share Posted September 10, 2007 uses simplexml to parse the xml, yes, but you said your class does that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.