如何找到多个XML节点的最小值&在WP-ALL-IMPORT中创建输出?

时间:2015-12-22 15:20:57

标签: php xml wordpress

我无法从外部XML Feed中获取多个xml节点的最低值。 Feed是此XML Feed:http://genusvs.co.uk/xml2015.xml

如您所见,所有xml值节点都被称为不同的东西。饲料中有8832辆汽车。这是一个例子。

<vehicle> <capid>32076</capid> <vehicleref>1100128291</vehicleref> <type>Car</type> <manufacturer>VAUXHALL</manufacturer> <model>ZAFIRA ESTATE</model> <shortmodtext>ZAFIRA</shortmodtext> <derivative>1.8i Design 5dr</derivative> <additionalfreetext/> <paint>Metallic</paint> <created>22/05/2015 00:20:00</created> <updated>22/05/2015 00:20:00</updated> <notes/> <discount>GENUS TERMS</discount> <dealercontribution>GENUS TERMS</dealercontribution> <deliverycharge/> <registeredstatus/> <registrationdate/> <mustbeorderedby/> <mustbedeliveredby/> <commission>300</commission> <source>ARVAL</source> <vrb/> <approxleadtime/> <doors>5</doors> <transmission>1</transmission> <fueltype>1</fueltype> <listprice/> <Price2Year10kMaintainedCH>568.0600</Price2Year10kMaintainedCH> <Price2Year10kNotMaintainedCH>548.8600</Price2Year10kNotMaintainedCH> <Price2Year20kMaintainedCH>605.5000</Price2Year20kMaintainedCH> <Price2Year20kNotMaintainedCH>569.9900</Price2Year20kNotMaintainedCH> <Price2Year30kMaintainedCH>647.4800</Price2Year30kMaintainedCH> <Price2Year30kNotMaintainedCH>591.5900</Price2Year30kNotMaintainedCH> <Price3Year10kMaintainedCH>452.9400</Price3Year10kMaintainedCH> <Price3Year10kNotMaintainedCH>427.4500</Price3Year10kNotMaintainedCH> <Price3Year20kMaintainedCH>489.2800</Price3Year20kMaintainedCH> <Price3Year20kNotMaintainedCH>447.2000</Price3Year20kNotMaintainedCH> <Price3Year30kMaintainedCH>528.0100</Price3Year30kMaintainedCH> <Price3Year30kNotMaintainedCH>465.8100</Price3Year30kNotMaintainedCH> <Price4Year10kMaintainedCH>391.8600</Price4Year10kMaintainedCH> <Price4Year10kNotMaintainedCH>361.2900</Price4Year10kNotMaintainedCH> <Price4Year20kMaintainedCH>424.9000</Price4Year20kMaintainedCH> <Price4Year20kNotMaintainedCH>378.7100</Price4Year20kNotMaintainedCH> <Price4Year30kMaintainedCH>488.3100</Price4Year30kMaintainedCH> <Price4Year30kNotMaintainedCH>403.4700</Price4Year30kNotMaintainedCH> <Price2Year10kMaintainedPCH>694.7160</Price2Year10kMaintainedPCH> <Price2Year10kNotMaintainedPCH>671.6760</Price2Year10kNotMaintainedPCH> <Price2Year20kMaintainedPCH>739.6440</Price2Year20kMaintainedPCH> <Price2Year20kNotMaintainedPCH>697.0320</Price2Year20kNotMaintainedPCH> <Price2Year30kMaintainedPCH>790.0200</Price2Year30kMaintainedPCH> <Price2Year30kNotMaintainedPCH>722.9520</Price2Year30kNotMaintainedPCH> <Price3Year10kMaintainedPCH>557.0040</Price3Year10kMaintainedPCH> <Price3Year10kNotMaintainedPCH>526.4160</Price3Year10kNotMaintainedPCH> <Price3Year20kMaintainedPCH>600.6120</Price3Year20kMaintainedPCH> <Price3Year20kNotMaintainedPCH>550.1160</Price3Year20kNotMaintainedPCH> <Price3Year30kMaintainedPCH>647.0880</Price3Year30kMaintainedPCH> <Price3Year30kNotMaintainedPCH>572.4480</Price3Year30kNotMaintainedPCH> <Price4Year10kMaintainedPCH>483.9240</Price4Year10kMaintainedPCH> <Price4Year10kNotMaintainedPCH>447.2400</Price4Year10kNotMaintainedPCH> <Price4Year20kMaintainedPCH>523.5720</Price4Year20kMaintainedPCH> <Price4Year20kNotMaintainedPCH>468.1440</Price4Year20kNotMaintainedPCH> <Price4Year30kMaintainedPCH>599.6640</Price4Year30kMaintainedPCH> <Price4Year30kNotMaintainedPCH>497.8560</Price4Year30kNotMaintainedPCH> <ncaprating>0</ncaprating> <co2>168</co2> <bhp/> <mpgcombined>39.2</mpgcombined> <zerotosixtytwo/> <topspeed/> <cc/> </vehicle>

我需要导入以读取所有价格,并且还创建所有2年,3年,4年 - 10k,20k,30k的维持和非维护的最低价格(不包括0或null),商业或个人,并将其作为自定义值导入..

我已经设法将它们更改为2位小数...为每个创建一个单独的函数,并为WP All Import的functions.php部分中的每个xml属性提供函数代码

例如

<?php // 10k - maintained - personal function p2y10kmp($p2y10kmp){ $p2y10kmp = number_format($p2y10kmp, 2, '.', ''); return $p2y10kmp;} function p3y10kmp($p3y10kmp){ $p3y10kmp = number_format($p3y10kmp, 2, '.', ''); return $p3y10kmp;} function p4y10kmp($p4y10kmp){ $p4y10kmp = number_format($p4y10kmp, 2, '.', ''); return $p4y10kmp;} ?>

我已经这样做,因为需要网站上不同地方的所有单独值......我正在努力弄清楚如何获得的最小值,将只是作为'来自£+增值税'

还有所有功能值

function p4y10knmp($p4y10knmp){ $p4y10kmp = number_format($p4y10kmp, 2, '.', ''); return $p4y10kmp; }

导入如

根据WP ALL IMPORT的要求

[([p4y10knmch({Price4Year10kNotMaintainedCH[1]})]

我也尝试从添加的函数值创建一个数组但是我无法使用min(数组)工作?

例子:`

$displayfrom =  min(array_diff(array_map('intval', $values), array(0))); return $displayfrom;`

如果有人可以提供帮助,我会乐意提供帮助,如果需要的话。

该网站目前正在www.cocoonoffers.uk上运行,如果你想获得我正在尝试做的事情的一个小工具,目前该网站是从本地版本的xml feed运行,只有21辆车进入饲料。完成后,将使用完整的8832汽车

(自定义字段中的价格值仅是[p4y10knmch({Price4Year10kNotMaintainedCH[1]})]

时的静态值

0 个答案:

没有答案