7 Replies Latest reply on Sep 23, 2016 10:17 AM by anna.antonioli

    XML Import

    anna.antonioli

      Hi all,

      I need to import into filemaker table an XML file as this:

       

      <?xml version="1.0" encoding="utf-8"?>
      <Account>
        <Field APIName="WrntyID">6029065</Field>
        <Field APIName="ExternalID">1761A</Field>
        <Field APIName="Name">sayIT SA</Field>
      </Account>

       

      now I'am trying to create the xls file.

      This is my xls file....

       

      <?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="WrntyID" TYPE="TEXT"/>
                      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ExternalID" TYPE="TEXT"/>
                      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Name" TYPE="TEXT"/>           
                  </METADATA>
                  <RESULTSET>
                      <ROW>
                          <COL>
                              <DATA><xsl:value-of select=“Account/Field[1]" /></DATA>
                          </COL>
                          <COL>
                              <DATA><xsl:value-of select=“Account/Field[2]” /></DATA>
                          </COL>
                          <COL>
                              <DATA><xsl:value-of select=“Account/Field[3]” /></DATA>
                          </COL>
                          </ROW>
                  </RESULTSET>
              </FMPXMLRESULT>
          </xsl:template>
      </xsl:stylesheet>

       

      This instruction <xsl:value-of select=“Account/Field[1]"/> doesn't work.

       

      What is the right syntax to retrive the value of the first TAG FIELD? Then the second end so on...?

      Many thanks

      Anna

        • 1. Re: XML Import
          nicolai

          slightly wrong xpath, I think. Try this:

           

          <xsl:value-of select=“/Account/Field[1]” />

           

          or this:

           

          <xsl:value-of select=“//Account/Field[1]” />

           

           

           

          • 2. Re: XML Import
            beverly

            Try this:

             

            <xsl:for-each select = "//Account"><ROW>

            <COL><DATA><xsl:value-of select="./Field[@APIName='WrntyID']" /></DATA></COL>

            <COL><DATA><xsl:value-of select="./Field[@APIName='ExternalID']" /></DATA></COL>

            <COL><DATA><xsl:value-of select="./Field[@APIName='Name']" /></DATA></COL>

            </ROW></xsl:for-each>

             

            Part of the problem may also be that there are two FIELD/Field elements (in the Account and in METADATA).

            If the above doesn't work, we can address making these unique. (but the import worked for me)

             

            beverly

            1 of 1 people found this helpful
            • 3. Re: XML Import
              beverly

              yep! that works, too. However I also found the XSLT has curly quotes, so that may be part of the problem.

               

              beverly

              • 4. Re: XML Import
                user19752

                Quotation should be simple double quote. "

                Smart quotes don't work.

                • 5. Re: XML Import
                  nicolai

                  Thanks, Beverly,

                   

                  I also managed to miss the request to import all records which you put in your post. xsl:for-each is the way to import all records (well, it is according to your book )

                  • 6. Re: XML Import
                    beverly

                    there may NOT be multiple Account segments. I just always plan for every element to repeat in some way.

                    for the Field element, it had different attribute values that could be leveraged to make them distinct. The [n] method works, but leaves it vague as to how the Field values may be different. Otherwise I might even put them into a related table (as I do for most repeating child elements).

                    beverly

                    • 7. Re: XML Import
                      anna.antonioli

                      Hi,

                      with simple double quote It's works.

                      I  tried the other syntax too and It's works.

                       

                      Many thanks,

                      Anna