Hi
I've been working on a script that goes through an xml feed that contains property data. I've got most of the property details being collected correctly, however I'm struggling with getting some particulars (such as number of bathroom). The problem for me is that I need to tally up all the bathrooms (type=8) and showerooms (type=13). Some properties don't always have this data, so in such instances I take the number of bedrooms divided by 3 (result being rounded up).
The issue I'm getting is that I can't reliably get an accurate number of total bathrooms & Showerrooms, which I can pass out to the main section. The results vary from accurate to quite a bit out especially if a particular type is listed more than once to indicate multiple rooms, as this feed lists rooms varyingly. e.g. type 13 may be listed 2 or 3 times (with number being 1 in each case). any advice appreciated.
My code for this section is:
foreach($advert->roomsList->room as $rooms) {
if ($rooms->type=="1") {
$bedrooms=$rooms->number;
}
if ($rooms->type=="8") {
$bathroom=$rooms->number;
}
if ($rooms->type=="13") {
$showerroom=$rooms->number;
}
}
The data is presented as follows
<estate id="xxxxxx" type="1">
<reference>286834349</reference>
<mandate_num>1810</mandate_num>
<mandate_type>1</mandate_type>
<roomsList>
<room id="3948806" rank="1">
<type>1</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>3</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948807" rank="2">
[b]<type>13</type>[/b]
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
[b]<number>1</number>[/b]
<coating></coating>
<floor></floor>
</room>
<room id="3948808" rank="3">
[b]<type>13</type>[/b]
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
[b] <number>1</number>[/b]
<coating></coating>
<floor></floor>
</room>
<room id="3948809" rank="4">
[b]<type>8</type>[/b]
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
[b]<number>1</number>[/b]
<coating></coating>
<floor></floor>
</room>
<room id="3948810" rank="5">
<type>30</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948811" rank="6">
<type>1</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948812" rank="8">
<type>1</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948813" rank="9">
<type>10</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948814" rank="10">
<type>41</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948815" rank="11">
<type>29</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948816" rank="12">
<type>1</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948817" rank="13">
<type>18</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
<room id="3948818" rank="7">
<type>43</type>
<comment lang="fr_FR"><![CDATA[]]></comment>
<area></area>
<number>1</number>
<coating></coating>
<floor></floor>
</room>
</roomsList>
</estate>
Thanks in advance for the help.
EDIT: it helps a lot when you put your code in
tags