Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to create a loop to import XML data from a list of urls

Featured Replies

  • 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.

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.

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 by Guest
File Removed

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.