Re: New use need your help
Brought to you by:
bs_php,
nigelswinson
|
From: Nigel S. <nig...@us...> - 2003-03-11 02:28:13
|
Thank you for your kind reply, now I can find the data I want.=20
But, I still couldn't find a way to count how many books are in the =
library?
count($xPath->match(/LIBRARY[1]/BOOK))
And I want to import the all book data(title, author,pages,price etc.) =
into a php array and present them to the user in other format.(For =
example a HTML form select menu options)
Is my idea workable with Xpath?
Yes very much so :o) Something along the lines of:
$aBookAddress =3D $xPath->match('/LIBRARY[1]/BOOK');
foreach($aBookAddress as $BookAddress) {
$aBook =3D array();
$aBook['Title'] =3D $xPath->getData($BookAddress.'/title');
$iISBN =3D $xPath->getAttribute($BookAddress.'/title', 'ISBN');
$aBooks[$iISBN] =3D $aBook;
}
(The above is completely untested, written off the top of my head, but =
it's a good template to start from)
Cheers
Nigel |