Hàm xml_parse_into_struct () trong PHP
❮ Tham chiếu trình phân tích cú pháp XML PHP
Thí dụ
Phân tích cú pháp dữ liệu XML thành một mảng (từ 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);
?>
Định nghĩa và Cách sử dụng
Hàm xml_parse_into_struct () phân tích cú pháp dữ liệu XML thành một mảng.
Hàm này phân tích dữ liệu XML thành 2 mảng:
- Mảng giá trị - chứa dữ liệu từ XML đã được phân tích cú pháp
- Mảng chỉ mục - chứa các con trỏ đến vị trí của các giá trị trong mảng Giá trị
Cú pháp
xml_parse_into_struct(parser, data, values, index)
Giá trị tham số
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | 1 về thành công. 0 khi thất bại |
---|---|
Phiên bản PHP: | 4.0+ |
❮ Tham chiếu trình phân tích cú pháp XML PHP