Php 用于复杂XML的SimpleXML加载文件函数?

Php 用于复杂XML的SimpleXML加载文件函数?,php,xml,parsing,simplexml,Php,Xml,Parsing,Simplexml,我试图使用此函数从响应中获取某些值 xml响应是: <details> <ID>355499958</ID> <parentID>94581</parentID> <parentTable>acNumber</parentTable> <title>Connected</title> <StartTime>2013-08-20 12:30:54</StartTime&g

我试图使用此函数从响应中获取某些值

xml响应是:

<details>

<ID>355499958</ID>
<parentID>94581</parentID>
<parentTable>acNumber</parentTable>
<title>Connected</title>
<StartTime>2013-08-20 12:30:54</StartTime>
<EndTime>2013-08-20 12:32:53</EndTime>
<connect>1.9902</connect>
<CLI>01234567890</CLI>
<dialledNumber>01234567890</dialledNumber>

<CData>
<DI N="opID" V="12345678" T="digitstring"/>
<DI N="account" V="1" T="digitstring"/>
<DI N="tID" V="1-2-3456789" T="digitstring"/>
<DI N="auth" V="test" T="digitstring"/>
<DI N="result" V="0" T="digitstring"/>
<DI N="accountID" V="" T="digitstring"/>
<DI N="tAmount" V="1000" T="digitstring"/>
<DI N="responseMessage" V="" T="digitstring"/>
</CData>

</details>

355499958
94581
acNumber
有联系的
2013-08-20 12:30:54
2013-08-20 12:32:53
1.9902
01234567890
01234567890
现在可以拉回第一个值之一,等等: echo$xml->CLI

但我需要从CData字段中获取单个值


我怎样才能做到这一点呢?

您可以使用
simplexml\u load\u string
simplexml\u load\u file

$xml = simplexml_load_string($xmlresponse);

echo $xml->ID; // 355499958

foreach($xml->CData->DI as $value)
{
    $att = $value->attributes();
    echo $att['N']; // opID
    echo $att['V']; // 12345678
    echo $att['T']; // digitstring
}
获取特定索引
tAmount
7.
行。所以
6.
数组中的索引。数组索引以零开始

$xml = simplexml_load_string($string);

$data = $xml->CData->DI[6]->attributes();

echo $data['N']; // tAmount
echo $data['V']; // 1000
echo $data['T']; // digitstring

行了,谢谢你。但我该如何具体地拉动(塔蒙特)呢?