diff --git a/test.py b/test.py index 11c938d..3a4806d 100644 --- a/test.py +++ b/test.py @@ -19,9 +19,14 @@ def main(): for book in collection.iter(ns + "entry"): bookout = {} - for datum in data: - d = book.find(ns + datum) - bookout[datum] = d.text if (d != None) else "" + bookout["title"] = book.find(ns + "title").text if (book.find(ns + "title") != None) else "" + bookout["isbn"] = book.find(ns + "isbn").text if (book.find(ns + "isbn") != None) else "" + authors = [] + if book.find(ns + "authors") != None: + for a in book.find(ns + "authors"): + authors.append(a.text) + bookout["authors"] = "; ".join(authors) + out.append(bookout.copy()) return render_template("books.html", books = out, data = data)