Old 08-04-2008, 04:09   #1 (permalink)
Paul
Junkie[scum]
 
Paul's Avatar
 
Join Date: Oct 2006
Location: location, location
Posts: 1,735
xpath search query

i have a xml doc like this
Code:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <root> .........

I'm looking to only show the properties in Alicante, so i have this
PHP Code:
foreach ($xml->xpath('//property[province="Alicante"]'); as $alicante) {

//do something....



this is not working, can someone tell me why?

Also I would like to split the results onto different pages. What is the best way to do this?

ta

Last edited by Paul : 09-04-2008 at 06:00.
  Reply With Quote
Old 08-04-2008, 08:07   #2 (permalink)
Paul
Junkie[scum]
 
Paul's Avatar
 
Join Date: Oct 2006
Location: location, location
Posts: 1,735
no-one?
  Reply With Quote
Old 08-04-2008, 08:22   #3 (permalink)
d3mcfadden
Senior Member
 
d3mcfadden's Avatar
 
Join Date: Apr 2005
Location: -
Posts: 694
Send a message via AIM to d3mcfadden
one obvious thing is the semicolon after the xpath expression in the foreach - remove that.

also, have you defined and constructed $xml?
  Reply With Quote
Old 08-04-2008, 08:31   #4 (permalink)
Paul
Junkie[scum]
 
Paul's Avatar
 
Join Date: Oct 2006
Location: location, location
Posts: 1,735
sorry, small typo in my post there. the code was fine.


PHP Code:
foreach ( $xml->xpath('//property[province="Alicante"]') as $alicante) {

// blah blah....



i have defined my $xml
PHP Code:
$propertiesfeed "properties.xml" ;
  
// load the XML file
  
$xml = @simplexml_load_file($propertiesfeed) or die ("no file loaded"); 


All i get is the same property looped?
  Reply With Quote
Old 09-04-2008, 05:59   #5 (permalink)
Paul
Junkie[scum]
 
Paul's Avatar
 
Join Date: Oct 2006
Location: location, location
Posts: 1,735
Got that sorted, however I'm struggling separating the results into span over multiple pages.

Should i create and array of the results and try split it that way??

i know i could us the LIMIT function for mysql, do i import the result into mysql and work from there
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8