5 Replies Latest reply on Mar 9, 2012 6:37 AM by OkcunSahin

    Import from XML Problem

    OkcunSahin

      Title

      Import from XML Problem

      Post

      Hi I am trying to get data from a weather site. Site is already offering xml. The xml is like this;
      <observations>
      <observation>
      <date>
      <pretty>Saat: 12:20 AM EET Tarih: 31 Aralık 2011</pretty>
      <year>2011</year>
      <mon>12</mon>
      <mday>31</mday>
      <hour>00</hour>
      <min>20</min>
      <tzname>Europe/Istanbul</tzname>
      </date>
      <utcdate>
      <pretty>Saat: 10:20 PM GMT Tarih: 30 Aralık 2011</pretty>
      <year>2011</year>
      <mon>12</mon>
      <mday>30</mday>
      <hour>22</hour>
      <min>20</min>
      <tzname>UTC</tzname>
      </utcdate>
      <tempm>-3.0</tempm>
      <tempi>26.6</tempi>
      <dewptm>-4.0</dewptm>
      <dewpti>24.8</dewpti>
      <hum>93</hum>
      <wspdm>3.7</wspdm>
      <wspdi>2.3</wspdi>
      <wgustm>-9999.0</wgustm>
      <wgusti>-9999.0</wgusti>
      <wdird>0</wdird>
      <wdire>Değişken</wdire>
      <vism>8.0</vism>
      <visi>5.0</visi>
      <pressurem>1014</pressurem>
      <pressurei>29.95</pressurei>
      <windchillm>-999</windchillm>
      <windchilli>-999</windchilli>
      <heatindexm>-9999</heatindexm>
      <heatindexi>-9999</heatindexi>
      <precipm>-9999.00</precipm>
      <precipi>-9999.00</precipi>
      <conds>Çok Bulutlu</conds>
      <icon>mostlycloudy</icon>
      <fog>0</fog>
      <rain>0</rain>
      <snow>0</snow>
      <hail>0</hail>
      <thunder>0</thunder>
      <tornado>0</tornado>
      <metar>
      METAR LTAC 302220Z VRB02KT 8000 SCT040 BKN100 M03/M04 Q1014 NOSIG
      </metar>
      </observation>
      <observation>

      So I created this xls file;

      <?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="yil" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="ay" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="gun" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="saat" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="dakika" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="sicaklik" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="cig" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="nem" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="ruzgar" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="ruzgaryon" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="basinc" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="sis" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="yagmur" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="kar" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="hail" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="firtina" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      <FIELD NAME="hortum" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
      </METADATA>

      <RESULTSET FOUND="">

      <xsl:for-each select="observation/date/utcdate">
      <ROW MODID="" RECORDID="">
      <COL><DATA><xsl:value-of select="year"/></DATA></COL>
      <COL><DATA><xsl:value-of select="month"/></DATA></COL>
      <COL><DATA><xsl:value-of select="mday"/></DATA></COL>
      <COL><DATA><xsl:value-of select="hour"/></DATA></COL>
      <COL><DATA><xsl:value-of select="min"/></DATA></COL>
      <COL><DATA><xsl:value-of select="tempm"/></DATA></COL>
      <COL><DATA><xsl:value-of select="dewptm"/></DATA></COL>
      <COL><DATA><xsl:value-of select="hum"/></DATA></COL>
      <COL><DATA><xsl:value-of select="wspdm"/></DATA></COL>
      <COL><DATA><xsl:value-of select="wdird"/></DATA></COL>
      <COL><DATA><xsl:value-of select="pressurem"/></DATA></COL>
      <COL><DATA><xsl:value-of select="fog"/></DATA></COL>
      <COL><DATA><xsl:value-of select="rain"/></DATA></COL>
      <COL><DATA><xsl:value-of select="snow"/></DATA></COL>
      <COL><DATA><xsl:value-of select="hail"/></DATA></COL>
      <COL><DATA><xsl:value-of select="thunder"/></DATA></COL>
      <COL><DATA><xsl:value-of select="tornado"/></DATA></COL>
      </ROW>
      </xsl:for-each>

      </RESULTSET>
      </FMPXMLRESULT>

      </xsl:template>
      </xsl:stylesheet>
      but the problem is it doesn't give an error but it never imports the data. Can I learn what I am doing wrong.
      Thanks.
       

        • 1. Re: Import from XML Problem

          Hi The problem is the x-path you use in the for-each select:

          <xsl:for-each select="observation/date/utcdate">

          That should read:

          <xsl:for-each select="observations/observation">

          and then some of the other x-path's are also slightly wrong:

          <COL><DATA><xsl:value-of select="/date/utcdate/year"/></DATA></COL>
          <COL><DATA><xsl:value-of select="/date/utcdate/month"/></DATA></COL>
          <COL><DATA><xsl:value-of select="/date/utcdate/mday"/></DATA></COL>
          <COL><DATA><xsl:value-of select="/date/utcdate/hour"/></DATA></COL>
          <COL><DATA><xsl:value-of select="/date/utcdate/min"/></DATA></COL>

          the rest should work fineafter these changes ;-)

          • 2. Re: Import from XML Problem
            OkcunSahin

            Hello again,

            Thank you for the update but it still doesn't take the data on the xml. And the problem is it thinks that everything is fine. The update screen appears but says that the number of imported record is 0.

            Thank you

            • 3. Re: Import from XML Problem
              OkcunSahin

              Maybe it is becaouse I didn't send the start of the xml can it be because of that? I am sending it again.

               

              <response>
              <version>0.1</version>
              <features>
              <feature>history</feature>
              </features>
              <history>
              <date>
              <pretty>Aralık 31, 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>31</mday>
              <hour>00</hour>
              <min>20</min>
              <tzname>Europe/Istanbul</tzname>
              </date>
              <utcdate>
              <pretty>Aralık 30, 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>30</mday>
              <hour>22</hour>
              <min>20</min>
              <tzname>UTC</tzname>
              </utcdate>
              <observations>
              <observation>
              <date>
              <pretty>Saat: 12:20 AM EET Tarih: 31 Aralık 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>31</mday>
              <hour>00</hour>
              <min>20</min>
              <tzname>Europe/Istanbul</tzname>
              </date>
              <utcdate>
              <pretty>Saat: 10:20 PM GMT Tarih: 30 Aralık 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>30</mday>
              <hour>22</hour>
              <min>20</min>
              <tzname>UTC</tzname>
              </utcdate>
              <tempm>-3.0</tempm>
              <tempi>26.6</tempi>
              <dewptm>-4.0</dewptm>
              <dewpti>24.8</dewpti>
              <hum>93</hum>
              <wspdm>3.7</wspdm>
              <wspdi>2.3</wspdi>
              <wgustm>-9999.0</wgustm>
              <wgusti>-9999.0</wgusti>
              <wdird>0</wdird>
              <wdire>Değişken</wdire>
              <vism>8.0</vism>
              <visi>5.0</visi>
              <pressurem>1014</pressurem>
              <pressurei>29.95</pressurei>
              <windchillm>-999</windchillm>
              <windchilli>-999</windchilli>
              <heatindexm>-9999</heatindexm>
              <heatindexi>-9999</heatindexi>
              <precipm>-9999.00</precipm>
              <precipi>-9999.00</precipi>
              <conds>Çok Bulutlu</conds>
              <icon>mostlycloudy</icon>
              <fog>0</fog>
              <rain>0</rain>
              <snow>0</snow>
              <hail>0</hail>
              <thunder>0</thunder>
              <tornado>0</tornado>
              <metar>
              METAR LTAC 302220Z VRB02KT 8000 SCT040 BKN100 M03/M04 Q1014 NOSIG
              </metar>
              </observation>
              <observation>
              <date>
              <pretty>Saat: 12:50 AM EET Tarih: 31 Aralık 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>31</mday>
              <hour>00</hour>
              <min>50</min>
              <tzname>Europe/Istanbul</tzname>
              </date>
              <utcdate>
              <pretty>Saat: 10:50 PM GMT Tarih: 30 Aralık 2011</pretty>
              <year>2011</year>
              <mon>12</mon>
              <mday>30</mday>
              <hour>22</hour>
              <min>50</min>
              <tzname>UTC</tzname>
              </utcdate>
              <tempm>-3.0</tempm>
              <tempi>26.6</tempi>
              <dewptm>-4.0</dewptm>
              <dewpti>24.8</dewpti>
              <hum>93</hum>
              <wspdm>3.7</wspdm>
              <wspdi>2.3</wspdi>
              <wgustm>-9999.0</wgustm>
              <wgusti>-9999.0</wgusti>
              <wdird>150</wdird>
              <wdire>GGD</wdire>
              <vism>7.0</vism>
              <visi>4.3</visi>
              <pressurem>1014</pressurem>
              <pressurei>29.95</pressurei>
              <windchillm>-999</windchillm>
              <windchilli>-999</windchilli>
              <heatindexm>-9999</heatindexm>
              <heatindexi>-9999</heatindexi>
              <precipm>-9999.00</precipm>
              <precipi>-9999.00</precipi>
              <conds>Çok Bulutlu</conds>
              <icon>mostlycloudy</icon>
              <fog>0</fog>
              <rain>0</rain>
              <snow>0</snow>
              <hail>0</hail>
              <thunder>0</thunder>
              <tornado>0</tornado>
              <metar>
              METAR LTAC 302250Z 15002KT 7000 SCT040 BKN100 M03/M04 Q1014 NOSIG
              </metar>
              </observation>
              <observation>
              • 4. Re: Import from XML Problem

                Hi, the solution now is very simple with the picture complete:

                the only change to my previous post would be: <xsl:for-each select="response/history/observations/observation">

                The complete sheet now looks like this:

                 

                <?xml version="1.0" encoding="UTF-8"?>
                <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
                        <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="yil" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="ay" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="gun" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="saat" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="dakika" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="sicaklik" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="cig" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="nem" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="ruzgar" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="ruzgaryon" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="basinc" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="sis" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="yagmur" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="kar" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="hail" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="firtina" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                    <FIELD NAME="hortum" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>
                                </METADATA>
                                <RESULTSET FOUND="">
                                    <xsl:for-each select="response/history/observations/observation">
                                        <ROW MODID="" RECORDID="">
                                            <COL><DATA><xsl:value-of select="/date/utcdate/year"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="/date/utcdate/month"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="/date/utcdate/mday"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="/date/utcdate/hour"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="/date/utcdate/min"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="tempm"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="dewptm"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="hum"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="wspdm"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="wdird"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="pressurem"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="fog"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="rain"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="snow"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="hail"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="thunder"/></DATA></COL>
                                            <COL><DATA><xsl:value-of select="tornado"/></DATA></COL>
                                        </ROW>
                                    </xsl:for-each>
                                </RESULTSET>
                            </FMPXMLRESULT>
                        </xsl:template>
                </xsl:stylesheet>

                • 5. Re: Import from XML Problem
                  OkcunSahin

                  Lessons of the short day:

                  1) I can not read xml files.

                  2) You can.

                   

                  Thank you very much