Nowadays web services become more and more popular and Most commonly used format for exchanging information in web services are XML because XML is simple to use and easy to read tag structures.
Let’s understand the code:
First of all, let’s generate XML code.
$xml = ''; $xml .= '
'; '; $xml .= ''; $xml .= ' 1'; $xml .= ' PHP'; $xml .= ' '; $xml .= ''; $xml .= ' 2'; $xml .= ' WordPress'; $xml .= '
Next, the main part of a code is a header, need to write a header to read XML content.To display XML file on browser use Content-type: text/XML header.
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: text/xml"); header ("Content-Description: PHP Generated Data" ); echo $xml;
That’s all there is to it.Anyway, I hope that helps some of you.If you have any questions please let me know via the comments.
Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.