PHP xml_parse_into_struct()関数
例
XMLデータを配列に解析します(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);
?>
定義と使用法
xml_parse_into_struct()関数は、XMLデータを配列に解析します。
この関数は、XMLデータを2つの配列に解析します。
- 値の配列-解析されたXMLからのデータを含みます
- インデックス配列-値配列内の値の場所へのポインタを含みます
構文
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 |
技術的な詳細
戻り値: | 成功した場合は1。失敗した場合は0 |
---|---|
PHPバージョン: | 4.0以降 |
❮PHPXMLパーサーリファレンス