【发布时间】:2014-08-21 14:58:46
【问题描述】:
我正在使用 PHP SOAP 从 Web 服务获取一些数据。我使用 __getLastResponse 从 Soap 客户端收到的数据似乎是围绕相关 XML 数据的 SOAP 信封,这很好,因为我随后计划将其转换为 SimpleXMLElement 以提取数据。
问题是数据看起来是正确的,直到它到达某个 <records> 标记,之后它将所有 &lt; 标记替换为 &lt;。
这是我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> 标记之前,开始标记会正确显示?之后,它会用&lt; 替换它们,直到它到达结束</records> 标记,当它继续正确显示开始标记时。它不影响结束标签或奇怪的引号。
这和CDATA 有关系吗?这就是我能想到的,虽然它没有说明任何地方都有CDATA的块......
谢谢。
【问题讨论】:
-
这个网络服务是公开的吗?你能把网址贴出来做一些测试吗?
-
不公开,恐怕是Web of Science检索期刊和论文的付费服务
-
您确定问题不在于 print_r 吗?您是否尝试将其转换为 SimpleXMLElement 对象?试试看,看看有没有错误。
-
它不会让我将其转换为 SimpleXMLElement 对象,因为由于
&lt;元素,它不会将其归类为格式良好的 XML。我拥有的变量是$string,它是上面列出的数据,它是另一个变量$search_client的子集,它是从SOAP 响应返回的Soap Client 对象。我从$search_client->__getLastResponse()得到$string。 -
<records>&lt;records。这是正常的吗?一个记录标签,有一个具有相同标签的孩子?
标签: php xml web-services soap soap-client