Using Native Data Structures

You may sometimes come across a situation that requires you to convert raw XML markup into native data structures such as variables, arrays, or custom objects. For these situations, PHP offers a very specialized little function named xml_parse_into_struct().

The xml_parse_into_struct() function requires four arguments:

  • A reference to the XML parser

  • The raw XML data to be processed

  • Two arrays to hold the data in structured form

After xml_parse_into_struct() has processed the XML document, it populates the two arrays with detailed information on the structure of the XML document. One array holds a list of all the elements encountered by the parser in its journey through the XML document; the other contains information ...

Get XML and PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.