Я хотел бы отобразить значение f25, в котором тег или строка, где есть максимальное значение f2 с помощью php.
вот XML-файл ..
<?xml version="1.0" encoding="ISO-8859-1"?>
<datafeed>
<quote f25="3M Company" f6="148.59" f14="3.54" f15="2.4405" f2="148.79" f3="144.81">24 Oct 19:59</quote>
<quote f25="Alcoa Inc." f6="16.55" f14="0.31" f15="1.9089" f2="16.57" f3="16.22">24 Oct 19:59</quote>
<quote f25="American Express Company" f6="86.4" f14="0.79" f15="0.9228" f2="86.43" f3="85.59">24 Oct 19:59</quote>
<quote f25="AT&T Inc." f6="33.87" f14="0.21" f15="0.6239" f2="33.94" f3="33.32">24 Oct 20:00</quote>
<quote f25="Bank of America Corporation" f6="16.72" f14="0.12" f15="0.7229" f2="16.72" f3="16.56">24 Oct 19:59</quote>
<quote f25="Boeing Company (The)" f6="122.24" f14="0.21" f15="0.1721" f2="122.84" f3="121.26">24 Oct 20:00</quote>
<quote f25="Caterpillar, Inc." f6="99.44" f14="0.17" f15="0.1713" f2="99.68" f3="98.37">24 Oct 19:59</quote>
<quote f25="Chevron Corporation" f6="115.91" f14="-0.28" f15="-0.241" f2="116.26" f3="114.53">24 Oct 19:59</quote>
<quote f25="Cisco Systems, Inc. " f6="23.78" f14="0.215" f15="0.9124" f2="23.8" f3="23.46">24 Oct 20:00</quote>
<quote f25="Coca-Cola Company (The)" f6="41.03" f14="0.17" f15="0.4161" f2="41.2699" f3="40.92">24 Oct 19:59</quote>
<quote f25="E.I. du Pont de Nemours and Company" f6="69" f14="0.41" f15="0.5978" f2="69.17" f3="68.14">24 Oct 19:59</quote>
<quote f25="Exxon Mobil Corporation" f6="94.49" f14="0.38" f15="0.4038" f2="94.53" f3="93.22">24 Oct 19:59</quote>
<quote f25="General Electric Company" f6="25.64" f14="0.2" f15="0.7862" f2="25.65" f3="25.41">24 Oct 19:59</quote>
<quote f25="Hewlett-Packard Company" f6="34.93" f14="-0.01" f15="-0.0286" f2="35.42" f3="34.735">24 Oct 19:59</quote>
<quote f25="Home Depot, Inc. (The)" f6="94.99" f14="0.19" f15="0.2004" f2="95.189" f3="94.13">24 Oct 19:59</quote>
<quote f25="Intel Corporation " f6="33.18" f14="0.49" f15="1.4989" f2="33.33" f3="32.57">24 Oct 20:00</quote>
<quote f25="International Business Machines Corporation" f6="162.08" f14="-0.1" f15="-0.0617" f2="162.44" f3="161.45">24 Oct 19:59</quote>
<quote f25="Johnson & Johnson" f6="103.13" f14="0.5" f15="0.4872" f2="103.29" f3="102.206">24 Oct 19:59</quote>
<quote f25="JP Morgan Chase & Co." f6="58.74" f14="0.68" f15="1.1712" f2="58.775" f3="58">24 Oct 19:59</quote>
<quote f25="McDonald's Corporation" f6="91.67" f14="0.65" f15="0.7141" f2="91.79" f3="90.55">24 Oct 19:59</quote>
<quote f25="Merck & Company, Inc. Common Stock (new)" f6="57.61" f14="0.98" f15="1.7305" f2="57.66" f3="56.63">24 Oct 19:59</quote>
<quote f25="Microsoft Corporation " f6="46.13" f14="1.11" f15="2.4656" f2="46.9" f3="45.18">24 Oct 20:00</quote>
<quote f25="Pfizer, Inc." f6="29.11" f14="0.51" f15="1.7832" f2="29.27" f3="28.71">24 Oct 19:59</quote>
<quote f25="Procter & Gamble Company (The)" f6="85.16" f14="1.93" f15="2.3189" f2="85.97" f3="84.91">24 Oct 19:59</quote>
<quote f25="The Travelers Companies, Inc." f6="97.73" f14="0.96" f15="0.992" f2="97.8067" f3="96.46">24 Oct 19:59</quote>
<quote f25="United Technologies Corporation" f6="103.82" f14="0.64" f15="0.6203" f2="103.87" f3="102.8">24 Oct 19:59</quote>
<quote f25="Verizon Communications Inc." f6="48.77" f14="0.55" f15="1.1406" f2="49.11" f3="48.1">24 Oct 19:59</quote>
<quote f25="Wal-Mart Stores, Inc." f6="76.38" f14="0.13" f15="0.1705" f2="76.5" f3="75.5">24 Oct 19:59</quote>
<quote f25="Walt Disney Company (The)" f6="88.61" f14="0.62" f15="0.7046" f2="88.655" f3="87.58">24 Oct 19:59</quote>
</datafeed>
ниже мой код, но он не работает полностью.
<?php
$xml = simplexml_load_file("stocks.xml") or die("Error: Cannot create object");
foreach($xml->children() as $cars){
$value[]=$cars->title['font'];
$data=array_map("floatval",$value);
}
echo max($data);
echo "<br>";
echo $cars->title['lang'];
?>
Задача ещё не решена.
Других решений пока нет …