Current Location: Home> Function Categories> xml_parse_into_struct

xml_parse_into_struct

Parsing XML data into an array structure
Name:xml_parse_into_struct
Category:XML parser
Programming Language:php
One-line Description:Parses XML data into an array.

Definition and usage

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

This function parses XML data into two arrays:

  • Value array - Contains data extracted from parsed XML
  • Index array - contains pointers to the data position in the value array

Example

Parses XML data into an array (parsed 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 the instance

grammar

 xml_parse_into_struct ( parser , data , values ​​, index )
parameter describe
parser Required. Specifies the XML parser to use.
data Required. Specifies the XML data to parse.
values Required. Specifies an array to store parsed XML data values.
index Optional. Specifies an array that stores a pointer to the data position in the value array.
Similar Functions
Popular Articles