Skip to content

Instantly share code, notes, and snippets.

@houssemz
Last active June 28, 2018 13:25
Show Gist options
  • Save houssemz/2bbb8e628dc7a84de94651e1056df439 to your computer and use it in GitHub Desktop.
Save houssemz/2bbb8e628dc7a84de94651e1056df439 to your computer and use it in GitHub Desktop.
PHP extension lets you create XML parsers and then define handlers for different XML events

Installation :

  • This extensio is enabled by default. It may be disabled by using the following option at compile time : --disable-xml if you comiple PHP ad a module for Apache
  • This extension has no configuration directives defined in php.ini

XML Parser functions :

xml_parser_create -> create an XML parser. xml_parser_create_ns -> create an XML parser with namespace support.

Character encoding :

There are 2 types of character encodings, source encoding and target encoding. By default, the document is always encoded with UTF-8.

  • 🚫 Source encoding is done when an XML document is parsed. This encoding can not be changed during parser lifetime.
  • 🚫 Target encoding is done when PHP passes data to XML handler functions this may be changed at any point.

SimpleXML :

  • The SimpleXML extension provides a very simple and easily toolset to convert XML to an object that can be processed with normal selectors and array iterators.

  • The SimpleXML extension requires PHP 5.

  • This extension is enabled by default. It may be disabled by using the following option at compile time: --disable-simplexml.

  • SimpleXML : OOP access for xml data :

    • elements become object properties
    • attributes can be accessed via associative arrays
    • SimpleXMLElement — The SimpleXMLElement class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment