Im trying to get the name atriburte of the type element in the following feed using xpath.
<response request="getHierarchyByMarketType" code="001"
message="success" debug="">
<jonny>
<class id="5" name="Formula 1" maxRepDate="2012-12-19" maxRepTime="15:03:34">
<type id="4558" name="F1 Championship" lastUpdateDate="2012-11-26"
lastUpdateTime="16:17:33">
to do this I'm using
$market_name = $wh_xml->xpath('/response/jonny/class/type/@name');
and then using
<h2>
<?= $market_name ?>
</h2>
in my view, but instead of it returning my expected "F1 Championship" im getting a:
Array to string conversion
notice, but I'm not sure why, I thought xpath would return the value of @name
as a string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…