I use curl to get the XML file link, get only the content, and no structure.
Like what:
123
Red
What you get is: 123 red
Would you like to set where?
Reply to discussion (solution)
Post the code to see.
function Curlxml ($url) { $header [] = "content-type:text/xml";//define Content-type as XML $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent '); curl_setopt ($ch, Curlopt_httpheader, $header); curl_setopt ($ch, Curlopt_binarytransfer, true); Get Data back $r = curl_exec ($ch) when Curlopt_returntransfer is enabled; Curl_close ($ch); return $r; } $url = "https://www.123456.com"; $value =curlxml ($url); Echo $value;
Because the links are generated temporarily, so there is no way to take up the test, please help me to see if it is also set where, thank you!
You just get the value and don't parse the generated XML, so you certainly won't get the effect you want.
Add a header before the output.
function Curlxml ($url) { $header [] = "content-type:text/xml";//define Content-type as XML $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent '); curl_setopt ($ch, Curlopt_httpheader, $header); curl_setopt ($ch, Curlopt_binarytransfer, true); Get Data back $r = curl_exec ($ch) when Curlopt_returntransfer is enabled; Curl_close ($ch); return $r; } $url = "https://www.123456.com"; $value =curlxml ($url); Header (' Content-type:text/xml;charset=utf-8 '); Echo $value;
Thank you upstairs, maybe I did not express clearly, I want to get the whole XML file including structure, I solved it myself, thank you