Latest web development tutorials
×

PHP corso

PHP corso PHP breve introduzione PHP installare PHP grammatica PHP variabile PHP echo/print PHP Tipi di dati PHP costante PHP stringa PHP operatori PHP If...Else PHP Switch PHP schieramento PHP Ordinamento di un array PHP superglobals PHP While circolazione PHP For circolazione PHP funzione PHP Variabili magici PHP Namespace PHP Object-Oriented

PHP modulo

PHP modulo PHP Forms Authentication PHP modulo - I campi obbligatori PHP modulo - e-mail di verifica e l'URL PHP esempio forma completa PHP $_GET variabile PHP $_POST variabile

PHP Tutorial avanzato

PHP array multidimensionali PHP data PHP contenere PHP file PHP File Upload PHP Cookie PHP Session PHP E-mail PHP sicurezza E-mail PHP Error PHP Exception PHP filtro PHP Filtro avanzato PHP JSON

PHP 7 nuove funzionalità

PHP 7 nuove funzionalità

PHP Database

PHP MySQL breve introduzione PHP MySQL collegamento PHP MySQL Creazione di un database PHP MySQL Creare una tabella di dati PHP MySQL inserire i dati PHP MySQL Inserire più dati PHP MySQL prepared statement PHP MySQL leggere i dati PHP MySQL WHERE PHP MySQL ORDER BY PHP MySQL UPDATE PHP MySQL DELETE PHP ODBC

PHP XML

XML Expat Parser XML DOM XML SimpleXML

PHP & AJAX

AJAX breve introduzione AJAX PHP AJAX Database AJAX XML AJAX ricerca in tempo reale AJAX RSS Reader AJAX voto

PHP Manuale di riferimento

PHP Array PHP Calendar PHP cURL PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP PDO PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones PHP Elaborazione immagini PHP RESTful

PHP xml_parse_into_struct function ()

PHP XML Reference Completa PHP XML Reference

Definizione e utilizzo

Funzione xml_parse_into_struct () per analizzare i dati XML in un array.

La funzione per analizzare i dati XML in due schiere:

  • array di Valore - contiene i dati dal XML analizzato
  • Index Array - contiene link a valori valore della posizione del puntatore

In caso di successo, la funzione restituisce 1. Se fallisce, restituisce 0.

grammatica

xml_parse_into_struct(parser,xml,value_arr,index_arr)

参数 描述
parser 必需。规定要使用的 XML 解析器。
xml 必需。规定要解析的 XML 数据。
value_arr 必需。规定 XML 数据的目标数组。
index_arr 可选。规定 index 数据的目标数组。


Suggerimenti e Note

Nota: la funzione xml_parse_into_struct ()restituisce 1 in caso di successo, restituisce 0 se fallisce. Questo è VERO e FALSO diverso, ad esempio, quando si utilizza l'operatore === di prestare attenzione.


Esempi

file XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

codice PHP

<?php
//invalid xml file
$xmlfile = 'test.xml';
$xmlparser = xml_parser_create();

// open a file and read data
$fp = fopen($xmlfile, 'r');
$xmldata = fread($fp, 4096);

xml_parse_into_struct($xmlparser,$xmldata,$values);

xml_parser_free($xmlparser);
print_r($values);
?>

L'output del codice sopra è il seguente:

Array
(
[0] => Array
(
[tag] => NOTE
[type] => open
[level] => 1
[value] =>
)
[1] => Array
(
[tag] => TO
[type] => complete
[level] => 2
[value] => Tove
)
[2] => Array
(
[tag] => NOTE
[value] =>
[type] => cdata
[level] => 1
)
[3] => Array
(
[tag] => FROM
[type] => complete
[level] => 2
[value] => Jani
)
[4] => Array
(
[tag] => NOTE
[value] =>
[type] => cdata
[level] => 1
)
[5] => Array
(
[tag] => HEADING
[type] => complete
[level] => 2
[value] => Reminder
)
[6] => Array
(
[tag] => NOTE
[value] =>
[type] => cdata
[level] => 1
)
[7] => Array
(
[tag] => BODY
[type] => complete
[level] => 2
[value] => Don't forget me this weekend!
)
[8] => Array
(
[tag] => NOTE
[value] =>
[type] => cdata
[level] => 1
)
[9] => Array
(
[tag] => NOTE
[type] => close
[level] => 1
)
)


PHP XML Reference Completa PHP XML Reference