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

    Importing XML



      Importing XML


      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"?>



      <Category Type="101">

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










      <Authority>COUNCIL PLACING AD</Authority>

      <Title>THE HACKNEY CARRIAGE</Title>

      <Title>TRO 539</Title>

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


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

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











        • 1. Re: Importing XML


          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">
          <PRODUCT BUILD="" NAME="" VERSION=""/>

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

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




           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

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


            Regards Nick