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 »
The xml_parse_into_struct() function parses XML data into an array.
This function parses the XML data into 2 arrays:
xml_parse_into_struct(
parser,
data,
values,
index)
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 |
Return Value: | 1 on success. 0 on failure |
---|---|
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!