July 9, 200916 yr Newbies Hi everyone and I really appreciate your time reading this. Project goal: to catalog a library of 2000+ books. Method: import xml data(title, author, publisher...etc) from isbndb.com into filemaker records for each book. So I have the above, now I can either manually import each book's properties by using FM's import xml tool, or I can create a script that will loop through a list of urls, something like this: http://isbndb.com/api/books.xml?access_key=2O6CQY46&index1=isbn&value1=0194371875 http://isbndb.com/api/books.xml?access_key=2O6CQY46&index1=isbn&value1=0805822623 http://isbndb.com/api/books.xml?access_key=2O6CQY46&index1=isbn&value1=0521589797 http://isbndb.com/api/books.xml?access_key=2O6CQY46&index1=isbn&value1=0906717388 and automatically import the data for each url. Fenton suggested from my originial question, here http://fmforums.com/forum/showtopic.php?tid/209736/pid/334133/post/last/m/1/ ,that I use this basic loop: Freeze Window Go To Record/Request [First] Loop Import XML [url,stylesheet] Go To Record/Request [Next, [x] Exit after last] (don't forget to check this) End Loop Commit Records [no dialog] But I dont understand how this loop works. I want to learn how script a loop that references a list of url, and at each instance assign the current url to a variable and input that into the Import XML [variable, stylesheet] For example, I have an excel list of urls, I run the script, and Filemaker goes through the excel list and import the xml data from each url into a new book record in my library. I hope I have made my question clear, thanks for your help.
July 15, 200916 yr Try using two separate tables: one for the URL's, one for the books. Import the URL's into one table (say, called List_of_URL's). Second table might be called Book_Data. Also create a global text field called URL_global Script might look like this: Go to Layout["URL_Table_Layout"] Go to record/request/page [first] Loop go to layout["URL_Table_Layout"] set field URL_global to individual_url go to layout["Book Data table layout")] perform script to import XML Go to record/request/page[next], exit after last End Loop where individual_url = field comprising URL There may be other ways to do this, but this is easy to follow. Another alternative is to simply paste the Excel URL list into a global field with clipboard and write a script to cycle through each line in that global field. It is also possible to look up book data using Amazon Web Services (E-Commerce Service). This is free.
July 15, 200916 yr Ah, I see what the problem is (which I didn't really think of, because my "library books" file either does 1 record at a time, or, like fseipel suggests, uses an ISBN list from another table. So, the question is really more, "How do I use Import within a Loop? Because the Import changes the found set to only the current record." There's a few methods to do this. One is to use a separate table. But there are ways to use the current table. The first, which seems simplest, is to create a new window, Import, then close the window. Which works, but it flashes each time, and looks a bit clunky. My favorite method is to "save" then "restore" the found set. The method can be learned here: http://www.sumware.net/robfm/savingfoundsets.php But it is actually fairly simple. And it is much faster than it sounds. It does not flash. It can be used in several situations. I've included all the methods in the example; but the 1st script is my favorite, and also fastest I think. I also moved your key to a separate Constants table. So others using this example can (please) go get your own free key, so we don't get kn199024 in trouble. Edited July 15, 200916 yr by Guest File Removed
July 15, 200916 yr Oops! I send only the FileMaker file, but not the xsl file. So likely everyone got an error, over and over. Sorry. ISBN_Loop.zip
Create an account or sign in to comment