感谢您的关注...我之前从未使用过API而且卡住了。这是从API返回的XML(改变了值,因为我认为它不应该公开)
<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<ext-support:lstData xmlns:ext-support="http://www.apitest.co.uk/whapi/ext-support-2.0">
<ext-support:categoryGroup name="Main Category Name">
<ext-support:category id="1">Support item 1</ext-support:category>
<ext-support:category id="2">Support item 2</ext-support:category>
</ext-support:categoryGroup>
<ext-support:categoryGroup name="Another Category Name">
<ext-support:category id="5">Another Support item 1</ext-support:category>
<ext-support:category id="6">Another Support item 2</ext-support:category>
</ext-support:categoryGroup>
</ext-support:lstData>
</resData>
</response>
</epp>
我正在使用;
$xml = new SimpleXMLElement($returned_xml);
但无法弄清楚如何获取对象内的数据。
我基本上想要遍历这个,所以我最终得到了
Main category name
Support item 1 (id:1)
Support item 2 (id:2)
Another category name
Another support item 1 (id:5)
Another support item 2 (id:6)
非常感谢任何帮助
谢谢
杰森
答案 0 :(得分:0)
管理用它进行排序(经过几个小时的试验和错误!)......
foreach ($xml->response->resData->children('ext-support', true)->lstData->categoryGroup as $group)
{
echo $group->attributes();
echo '<br/>';
foreach ($group->category as $cat)
{
echo $cat;
echo $cat->attributes();
echo '<br/>';
}
}
非常感谢!