PHP - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PHP XML

PHP XML

shape Description

XML stands for Extensible Markup Language and it will have separate file like HTML, SGML. XML is the open source and utilized to create common information formats and share both format and the information on the World Wide Web. An XML document has statements enclosed between < and >. The two main differences between PHP XML and HTML −
  • XML doesn't put any limits to use a specific set of tags
  • XML follows document structure

shape Example

Parsing PHP XML Document

PHP XML allows to create custom HTML tags. PHP SimpleXML module converts an XML document into an object that provides structured access to the XML. To create a SimpleXML object from an XML document stored in a string, pass the string to simplexml_load_string( ). It returns a SimpleXML object. [xml] <html> <body> <?php $note=<<<XML <note> <to>Tony</to> <from>Rita</from> <heading>Project submission</heading> <body>Please see clearly </body> </note> XML; $xml=simplexml_load_string($note); print_r($xml); ?> </body> </html> [/xml] Output: [php] SimpleXMLElement Object ( [to] => Tony [from] => Rita [heading] => Project submission [body] => Please see clearly ) [/php]

Summary

shape Key Points

  • XML stands for Extensible Markup Language
  • SimpleXML module converts an XML document into an object that provides structured access to the XML.