2 Replies Latest reply on Nov 25, 2009 12:04 PM by goodhope

    Importing XML

    goodhope

      Title

      Importing XML

      Post

      Hello Everyone,

       

      I'm new to Filemaker and have a requirement to import XML. I understand that in order to do this you must firstly transform the XML into a type that Filemaker can understand. I gather this is via an XSLT - unfortunately I'm no XSLT expert! I do see that I can use a standard XSLT provided by Filemaker called 'msdo_elem.xslt' on my XML file - which I have - unfortunately I don't get the result I'm after - which is to import each element into a separate field within a record (what I get in this instance is the entire XML file in one field.

       

      Any help would be gratefully accepted - Thanks in advance.

       

      Regards Nick 

       

      Please see below the structure of my XML document (in this case I have cut it down to one record, but the XML file I wish to import has many of the same type - each record to start with <Notice> and end with </Notice>):

       

       <?xml version="1.0" encoding="UTF-8"?>

      <Paper>

      <Body>

      <Category Type="101">

      <Notice Type="2" Reference="123456">

      <Metadata>

      <PublishDate>2009-02-15</PublishDate>

      <SupplierNoticeID>2</SupplierNoticeID>

      <KeyedBy>jim</KeyedBy>

      <SortKey/>

      <Language>English</Language>

      <NoticeClass>Standard</NoticeClass>

      <TimeStamp>8:22:38.652</TimeStamp>

      </Metadata>

      <Authority>COUNCIL PLACING AD</Authority>

      <Title>THE HACKNEY CARRIAGE</Title>

      <Title>TRO 539</Title>

      <Para><Text>NOTICE IS GIVEN.</Text></Para>

      <Administration>

      <DateSigned>24<Superior>th</Superior> day of June 2009</DateSigned>

      <Administrator><PersonName Class="Administrator"><Forename>Nick</Forename> <Surname>Jones</Surname></PersonName></Administrator>

      <Administrator>Assistant</Administrator>

      <Administrator>Officer</Administrator>

      </Administration>

      </Notice>

      </Category>

      </Body>

       

      </Paper>

       

       

        • 1. Re: Importing XML
          comment_1
            

           

          Here's a simple stylesheet that will import three fields out of your document:

           

          <?xml version="1.0" encoding="UTF-8"?>
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

          <xsl:template match="/">

          <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
          <ERRORCODE>0</ERRORCODE>
          <PRODUCT BUILD="" NAME="" VERSION=""/>
          <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>

          <METADATA>
          <FIELD NAME="Reference" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
          <FIELD NAME="Authority" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
          <FIELD NAME="DateSigned" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
          </METADATA>

          <RESULTSET FOUND="">

          <xsl:for-each select="Paper/Body/Category/Notice">
          <ROW MODID="" RECORDID="">
          <COL><DATA><xsl:value-of select="@Reference"/></DATA></COL>
          <COL><DATA><xsl:value-of select="Authority"/></DATA></COL>
          <COL><DATA><xsl:value-of select="Administration/DateSigned"/></DATA></COL>
          </ROW>
          </xsl:for-each>

          </RESULTSET>
          </FMPXMLRESULT>

          </xsl:template>
          </xsl:stylesheet>

           

           To add more fields, define them in the <METADATA> section, and select what to pick for them in the <ROW> element.

           

           

           

          NOTE: Instead of the smiley, it should read "xsl: output" (without the space)


           
















          • 2. Re: Importing XML
            goodhope
              

            Thanks very much for that. I'll give it a blast.

             

            Regards Nick