简体   繁体   中英

Filemaker Pro and Import.IO. How to import into FMP using Import.IO API?

I have a nice web scraper in Import.IO and I want to set up automatic uploads from Import.IO into Filemaker Pro. I've spent months on this and I have no idea why it does not work. Here is what I've done. I won't go into the Import.IO stuff in detail, as in the end you have options to export in Excel, CSV, JSON, or using RESTful type technology which is what I want, via their API. I've got my API, but when I import it into FMP, I always get this error

"Error in line 1, char 1".

The stylesheet I've developed by hand is as follows:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
            <METADATA>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Input" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Result Number" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Widget" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Data Origin" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Result Row" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Source Page URL" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Link" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="f8" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="f9" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="f10" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Address" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Price" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Availability" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Baths" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Beds" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Cars" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="New" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Open" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Agent" TYPE="TEXT"/>
            </METADATA>
            <RESULTSET>
                <ROW>
                    <COL><DATA><xsl:value-of select="@input"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Result Number"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Widget"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Data Origin"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Result Row"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Source Page URL"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Link"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@f8"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@f9"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@f10"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Address"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Price"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Availability"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Baths"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Beds"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Cars"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@New"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Open"/></DATA></COL>
                    <COL><DATA><xsl:value-of select="@Agent"/></DATA></COL>
                </ROW>
            </RESULTSET>
        </FMPXMLRESULT> 
    </xsl:template>
</xsl:stylesheet>

Questions:

  1. How can I validate the above stylesheet against my data from Import.IO? I am happy to export it into Excel and test it from there.

  2. Is there anything obviously wrong with the stylesheet above?

  3. How can I put in here my API so someone else can test it in FMP?

FMP is a great system, but it's RESTful documentation is poor to crap to be honest. I have very little knowledge of web services, XML importing and RESTful protocols, so any other suggestions will be appreciated.

Thank you

UPDATE Look guys I am not an XML guru or know anything really about XSL and stylesheets. All I want is to be able to use an API from Import.IO to import data into Filemaker Pro. It's as simple as that! I don't want to have to create a server, or a translator, or fancy stuff. I would have thought that the Import.IO API would have been enough, and their videos imply this (not with FMP though). So unless you guys care to step into my world, create a free Import.IO account, create an API and test it with FMP, then I really don't know what more I can give you. I am a total beginner at XML, XSL, and RESTful what ever it's called. I am not asking you to spoon feed me either. I just need a proper example of how to make this work - if it works at all! The only alternative I have is to export my web scraped data from Import.IO as a CSV and import it directly into a temporary table into FMP. So easy, but so MANUAL! There must be an automatic solution to this. Thank you

Unless you are passing a single node with 19 attributes your stylesheet does not make sense. Which brings the second question - why some of your attributes have spaces. I don't now Import.IO but this will break general XML rules.

You don't validate your stylesheet, you should validate your XML. Stylesheet is either works or it does not - you just test it.

Try to post your sample XML with the help on your stylesheet.

FIleMaker is not a RESTful application, I don't know what documentation you are referring to. If you need to use RESTful look at restfm:

http://www.restfm.com/

Is there anything obviously wrong with the stylesheet above?

Yes, several things. First, names in XML cannot contain spaces - so when you call for:

<xsl:value-of select="@Result Number"/>

or:

<xsl:value-of select="@Data Origin"/>

that will produce an error.

Next, your context is the root / node, which cannot have attributes . As a result, all your DATA elements will be empty.

That doesn't mean that the error you report is caused by any of these flaws. It probably isn't.

How can I put in here my API so someone else can test it in FMP?

Doesn't your API have a URL?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM