View Full Version : Array from XML

03-05-2007, 02:30 AM
I'm trying to customize a php library administration system to fit my needs. In the system, when I choose to add a book, I'm taken to a page asking to enter ISBN(ASIN). I type it and I accept, then I'm taken to a page to fill the rest of the info about the book. Well, the whole question is about lazyness: I need the system to check ISBNdb.com (a public ISBN database) for that book and fill the data for me. Till now, I've managed to check the information, but I'm an absolute newbie and I don't know how can I ask php to analyze the XML answer from ISDNdb and drop the information on an array. I don't even know how to define an array, indeed.
XML answer is something like that:

<ISBNdb server_time="2007-03-05T01:40:40Z">
<BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="works_of_oscar_wilde" isbn="1851705384">
<Title>Works of Oscar Wilde</Title>
<AuthorsText>Oscar Wilde, Timothy Gaynor (Editor)</AuthorsText>
<PublisherText publisher_id="senate">Senate</PublisherText>
<Details dewey_decimal="" physical_description_text="800 pages" language="" edition_info="Unknown Binding; 1997-07-25" dewey_decimal_normalized="" lcc_number="" change_time="2007-03-05T00:10:26Z" price_time="2007-03-05T00:10:47Z"/>

I need, then, to have the text between <Title> and </Title> in $o_livre->Title
the one between <AuthorsText> and </AuthorsText> in $o_livre->AuthorsText
the publisher in $o_livre->PublisherText
the text after edition_info=" and before the ; (Unknown Binding) in $o_livre->Lieu
and the date after the ; in $o_livre->ReleaseDate
I'm calling to a function in the main php file this way:

and the function, in functions.inc, is:

function get_book_isbn($rechcode)

Many thanks for your help!

03-05-2007, 05:47 PM

03-05-2007, 09:32 PM
heh I didn't know that existed
I've been doing things the hard way

03-05-2007, 09:33 PM
nikemen, I think I saw this script over at amazon.com