PHP xml_parse_into_struct() Function

❮ PHP XML Parser Reference

Example

Parse XML data into an array (from note.xml):

<?php
$xmlparser = xml_parser_create();

$fp = fopen("note.xml", "r");
$xmldata = fread($fp, 4096);

// Parse XML data into an array
xml_parse_into_struct($xmlparser,$xmldata,$values);

xml_parser_free($xmlparser);
print_r($values);
fclose($fp);
?>
Run Example »

Definition and Usage

The xml_parse_into_struct() function parses XML data into an array.

This function parses the XML data into 2 arrays:

  • Value array - containing the data from the parsed XML
  • Index array - containing pointers to the location of the values in the Value array

Syntax

xml_parse_into_struct(parser, data, values, index)

Parameter Values

Parameter Description
parser Required. Specifies the XML parser to use
data Required. Specifies the XML data to parse
values Required. Specifies an array with the values of the XML data
index Optional. Specifies an array with pointers to the location of the values in values


Technical Details

Return Value: 1 on success. 0 on failure
PHP Version: 4.0+

❮ PHP XML Parser Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.