我有一些xml定义了住宅或商业属性列表。它们也分为出售或出售。以下是XML的示例:
<property>
<property_ref>768</property_ref>
<building_number></building_number>
<address1>Celia Fiennes House, 8-20 Well Street, London, E9 7PX</address1>
<address2>Celia Fiennes House</address2>
<address3>8-20 Well Street</address3>
<town>London</town>
<county>London</county>
<region>London.</region>
<country>ENGLAND</country>
<postcode>E9 7PX</postcode>
<property_types>
<type_description>Office</type_description>
</property_types>
<job_type>Disposal (Sale/Let)</job_type>
<property_status>To Let</property_status>
......
我需要能够根据property_types-&gt; type-description字段以及job_type值选择属性。我已经设法根据type_description值选择属性:
foreach($xml->children() as $property)
{
// check property_types
$selectProperty = false;
foreach ($property->property_types->type_description as $type)
{
if($type == "my value")
{
$selectProperty = true;
}
}
if($selectProperty)
{
// show the property on this page...
但是,我如何检查job_type的值?
感谢您的帮助!
答案 0 :(得分:0)
你也不能像这样检查job_type吗?
if ($selectProperty && (string)$property->job_type == 'my job type')
{
// show the property on this page...
在检查类型描述之前或之后检查作业类型似乎很简单,然后将每个检查的布尔结果与逻辑AND运算符组合。