I'm creating a PHP script that would get the value of tag/element from an xml response. Here's the URL that gives the response: http://stageapi.myprepaid.co.za/Api/ConsumerRegisterRequest/21b6e114-010a-e311-a672-00155d4905d3
我正在创建一个PHP脚本,它将从xml响应中获取tag / element的值。这是给出回复的URL:http://stageapi.myprepaid.co.za/Api/ConsumerRegisterRequest/21b6e114-010a-e311-a672-00155d4905d3
If you're trying to access the URL on the browser, you'll get an XML file, but when using file_get_contents() The format of the xml changes. The xml becomes somewhat like:
如果您尝试访问浏览器上的URL,您将获得一个XML文件,但是当使用file_get_contents()时,xml的格式会发生变化。 xml变得有点像:
{"ID":"e5d1b161-110a-e311-a672-00155d4905d3","Email":null,"Mobile":null,"Password":null,"MeterNumber":"1234567890","Bank":"ABSA","CampaignID":"1040","WebBrowserIdentifierString":null,"Status":"Pending...
Do you have other ways on how to get the XML and preserving its format? So that I could use SimpleXMLElement.
您是否有其他方法可以获取XML并保留其格式?这样我就可以使用SimpleXMLElement了。
Thanks!
1 个解决方案
#1
0
Try to use cURL with browser's headers. That should help you to have the same format as you need.
尝试将cURL与浏览器的标题一起使用。这应该可以帮助您拥有所需的相同格式。
#1
0
Try to use cURL with browser's headers. That should help you to have the same format as you need.
尝试将cURL与浏览器的标题一起使用。这应该可以帮助您拥有所需的相同格式。