Hi there, new to both XML and PHP so after some time finding myself more and more lost. I’m trying to have all results returned from an XML, at the moment its defaulting to 10. I’d like to know what code I should use and where to place it to return all items in xml. (example xml has only 2)
Here is the PHP code…
<?php
$postUrl = get_permalink($aParams['page_id']);
$mode = isset($aParams['mode']) ? $aParams['mode'] : '';
$aRows = $aSearch = array();
$aSearch = $_POST['search'];
//echo "<pre>"; print_r($aSearch); echo "</pre>";
$xmlFile = "property.xml";
if($mode == "letting")
{
$searchUrl = $mainApiUrl.'search?sales=false';
}
else
{
$searchUrl = $mainApiUrl.'search?sales=true';
}
if($aSearch['beds'] > 0)
{
$searchUrl .= "&beds=".$aSearch['beds'];
}
if($aSearch['minprice'] > 0)
{
$searchUrl .= "&min=".$aSearch['minprice'];
}
if($aSearch['maxprice'] > 0)
{
$searchUrl .= "&max=".$aSearch['maxprice'];
}
if($aSearch['ptype'] > 0)
{
$searchUrl .= "&type=".$aSearch['ptype'];
}
if($aSearch['maxprice'] > 0)
{
$searchUrl .= "&location=".$aSearch['location'];
}
if($aSearch['pricerange'])
{
$pricerange = explode("-",$aSearch['pricerange']);
$searchUrl .= "&min=".$pricerange[0];
if($pricerange[1] > 0)
{
$searchUrl .= "&max=".$pricerange[1];
}
}
//echo $searchUrl;
$aCurl = curl_init($searchUrl);
curl_setopt($aCurl, CURLOPT_RETURNTRANSFER, true);
$curlData = curl_exec($aCurl);
$showResult = 0;
?>
<div id="property-list-wrapper">
<?php
if($curlData)
{
file_put_contents($xmlFile, $curlData);
if(file_exists($xmlFile))
{
$aRows = simplexml_load_file($xmlFile);
if($aRows->property)
{
$showResult = 2;
?>
<?php
foreach($aRows->property as $akey => $aRow)
{
$image = plugins_url( 'no_image_thumb.gif', dirname(__FILE__) );
$propUrl = $postUrl."?property_id=".$aRow->id;
And an example of the xml i’m trying to extract from…
<properties>
<firstItem>1</firstItem>
<lastItem>1</lastItem>
<totalItems>2</totalItems>
<page>1</page>
<previousPage>0</previousPage>
<showNext>true</showNext>
<nextPage>2</nextPage>
<searchString></searchString>
<property>
<id>1</id>
<type>Detached</type>
<bedrooms>1 bedroom</bedrooms>
<price>195950</price>
<tenure>Leasehold</tenure>
<photoID>1</photoID>
<rentFrequency></rentFrequency>
<status>Available</status>
<address>
<advertising>Palmeira Avenue, Hove, East Sussex, BN3
3NT</advertising>
<name></name>
<number>2</number>
<street>Palmeira Avenue</street>
<locality></locality>
<town>Hove</town>
<county>East Sussex</county>
<postcode>BN3 3NT</postcode>
<country>GB</country>
<latitude>50.826965</latitude>
<longitude>-0.163236</longitude>
</address>
<description>Edwardian property. Recently refurbished
kitchen.</description>
</property>
</properties>