Help, all brains broke. There is XML of this type:

<document> <data id="candles"> <metadata> <columns> <column name="open" type="double"/> <column name="close" type="double"/> <column name="high" type="double"/> <column name="low" type="double"/> <column name="value" type="double"/> <column name="volume" type="double"/> <column name="begin" type="datetime" bytes="19" max_size="0"/> <column name="end" type="datetime" bytes="19" max_size="0"/> </columns> </metadata> <rows> <row open="88.62" close="88.8" high="90.4" low="87.82" value="95995067.1" volume="1078590" begin="2015-01-12 00:00:00" end="2015-01-12 23:59:59"/> 

etc.

How can I select only the value of the "close" attribute in the row row by XPath?

Of course you can do so

 $xml = new SimpleXMLElement($content); $last = $xml->xpath("data/rows/row[last()]"); echo $last['0']['close']; 

(and yes, I need the lowest row, so I have last ()) But I believe that you can make more beautiful! Help!

  • The best is the enemy of the good :) - artoodetoo

1 answer 1

It is possible so:

 $xml->xpath("//rows/row/@close")