我正在使用PHP SOAP从Web服务获得一些数据。我使用__getLastResponse
从Soap客户机接收到的数据似乎是围绕相关XML数据的Soap信封,这很好,因为我随后计划将其转换为SimpleXMLElement
以提取数据。
问题是,数据看起来是正确的,直到它碰到一个特定的<records>
标签,之后它用<
替换所有的<
标签。
这是什么数据看起来像当我print_r
它(这只是一个小的例子,完整的数据):
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchResponse xmlns:ns2="http://woksearch.v3.wokmws.thomsonreuters.com"><return><queryId>1</queryId><recordsFound>16492</recordsFound><recordsSearched>38802522</recordsSearched><records><records xmlns="http://scientific.thomsonreuters.com/schema/wok5.4/public/FullRecord">
<REC r_id_disclaimer="ResearcherID data provided by Thomson Reuters"><UID>WOS:000257367300002</UID><static_data><summary><EWUID><WUID coll_id="WOS"></WUID><edition value="WOS.SCI"></edition></EWUID><pub_info issue="8" pubtype="Journal" sortdate="2008-07-01" has_abstract="Y" coverdate="JUL 2008" pubmonth="JUL" vol="17" pubyear="2008"><page end="1820" page_count="16" begin="1805">1805-1820</page></pub_info><titles count="6"><title type="source">BIODIVERSITY AND CONSERVATION</title>...etc...</static_data><dynamic_data><citation_related><tc_list><silo_tc local_count="16" coll_id="WOS"></silo_tc></tc_list></citation_related><cluster_related><identifiers><identifier value="0960-3115" type="issn"></identifier><identifier value="10.1007/s10531-007-9267-2" type="doi"></identifier><identifier value="10.1007/s10531-007-9267-2" type="xref_doi"></identifier></identifiers></cluster_related></dynamic_data></REC>
</records></records></return></ns2:searchResponse></soap:Body></soap:Envelope>
为什么开始标签显示正确,直到它得到第二个<records>
标签?之后,它将它们替换为<
,直到到达结束的</records>
标记,当它继续正确显示开始标记时。它不影响结束标签或引号,这很奇怪。
这是否与CDATA
有关?这就是我所能想到的,尽管它没有说明在任何地方都有一个CDATA
块…
谢谢。
我也有同样的问题,不知道这是不是一个"好的"解决方案,但至少它是有效的:
$xmlP = html_entity_decode($client->__getLastResponse());
这是将html实体解码回html。& lt;和>正确地存在于字符串中,保持不变。
希望对大家有所帮助