我遇到了一个分析错误,因为某种原因。我把它缩小到“什么”而不是“为什么”。
这是我的测试脚本:
<?php
$xml_string = <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AccountsGetXMLResponse xmlns="https://test.testsite.com/v3.0/">
<AccountsGetXMLResult>
<AccountsWSDS xmlns="">
<CUSACCOUNTS><ACCOUNT_ID>6036335098370413</ACCOUNT_ID><ACTIVE_FLAG>N</ACTIVE_FLAG><IN_USE>Y</IN_USE><ACCOUNT_BALANCE>0</ACCOUNT_BALANCE></CUSACCOUNTS>
<CUSACCOUNTS><ACCOUNT_ID>6036335098370414</ACCOUNT_ID><ACTIVE_FLAG>N</ACTIVE_FLAG><IN_USE>Y</IN_USE><ACCOUNT_BALANCE>0</ACCOUNT_BALANCE></CUSACCOUNTS>
<META_INFO><INFO_CLASS>TableInfo</INFO_CLASS><INFO_TYPE>Accounts</INFO_TYPE><INFO_CODE>PageSize</INFO_CODE><VALUE>10</VALUE></META_INFO>
<META_INFO><INFO_CLASS>TableInfo</INFO_CLASS><INFO_TYPE>Accounts</INFO_TYPE><INFO_CODE>PageNumber</INFO_CODE><VALUE>1</VALUE></META_INFO>
<META_INFO><INFO_CLASS>TableInfo</INFO_CLASS><INFO_TYPE>Accounts</INFO_TYPE><INFO_CODE>RowCount</INFO_CODE><VALUE>200</VALUE></META_INFO>
<META_INFO><INFO_CLASS>TableInfo</INFO_CLASS><INFO_TYPE>Accounts</INFO_TYPE><INFO_CODE>PageCount</INFO_CODE><VALUE>20</VALUE></META_INFO>
</AccountsWSDS>
</AccountsGetXMLResult>
<rowCount>200</rowCount>
<pageCount>20</pageCount>
</AccountsGetXMLResponse>
</soap:Body>
</soap:Envelope> ;
if( ! $xml = simplexml_load_string( $xml_string ) )
{
echo "Unable to load XML string";
}
else
{
echo "XML String loaded successfully";
}
?>
With the testing xml string above I get the "Unable....." condition. However, when I take out the "" it works! Obviously simplexml_load_string() has some particulars. But I m receiving this response with the , and I don t want to have to do a find/replace script first.
而且,我这样做对吗?最后我需要开始分析CUSACCOUNTS, 提取里面的数据。