Check if remote file is well-formed XML with PHP

倾然丶 夕夏残阳落幕 提交于 2019-11-30 13:46:12

Use cURL to get the result and simplexml to check if the XML is well-formed.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://remote.com/client.asp");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
if (simplexml_load_string($output)) {
  // well-formed XML
} else {
  // it isn't
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!