PHP uses DOM parsing to obtain the author and title of each book & lt ;? Php & nbsp; $ docnewDOMDocument (1.0, UTF-8); & nbsp; $ doc-& gt; load (book. xml); & nbsp; $ books $ doc-& gt; getElementsByTagName (book); & nbsp; $ PHP obtains the author and title of each book through DOM parsing.
$ Doc = new DOMDocument ('1. 0', 'utf-8 ');
$ Doc-> load ('Book. XML ');
$ Books = $ doc-> getElementsByTagName ('book ');
$ First_book = $ books-> item (0 );
$ First_title = $ first_book-> getElementByTagName ('title')-> item (0)-> nodeValue;
$ First_author = $ first_book-> getElementByTagName ('author')-> item (0)-> nodeValue;
$ Second_book = $ books-> item (1 );
$ Second_title = $ second_book-> getElementsByTagName ('title ');
$ Tar = $ title-> item (0 );
$ Text = $ tar-> nodeValue;
$ Third_book = $ books-> item (2 );
$ Third_title = $ third_book-> getElementsByTagName ('title')-> item (0)-> nodeValue;
$ Third_author = $ third_book-> getElementsByTagName ('author')-> item (0)-> nodeValue;
Var_dump ($ third_title );
Var_dump ($ third_author );
?>