我试图获取另一个标记内的标记的内容以及指定ID标记。源是以下XML响应:如何使用php获取父标记的子标记的内容使用php
XML响应是这里
<PricePlans>
<PricePlan>
<Description>Check Email</Description>
<ID>1</ID>
<Price>2</Price>
<Time>900</Time>
</PricePlan>
<PricePlan>
<Description>High Speed</Description>
<ID>2</ID>
<Price>5</Price>
<Time>3600</Time>
</PricePlan>
</PricePlans>
我的PHP代码是在这里:
echo "Desc" ." ".$xml->PricePlan->Description ."</br>";
此代码给我的第一个内容“描述”标签(检查电子邮件),但我想要描述具有特定“ID”标签的价格计划(例如ID 2 - “高速”) xml响应可能有更多“Pr icePlan“标签,但每个在”ID“标签中都有唯一的值。