12 Replies Latest reply on Nov 7, 2016 11:46 AM by malachydevlin

    export to XML


      Hi, I am not familiar with exporting to XML and ordered could I ask for help on how to export just 2 fields to this format XML







        • 1. Re: export to XML

          To export to XML, FM uses one of its own XML grammars.  If you want the end result to be a different kind of XML grammars then you need to write an XSLT style sheet to do the transformation from one grammar into the other.  You can then specify the XSLT sheet as part of the export script step.


          Another option - given how simple the desired XML structure is - is to just create the XML in a script and treat it as a text parsing / merging exercise.

          • 2. Re: export to XML

            Plus what Wim says.


            Is the example really as simple as that or are there other things that need to be in the XML? Is there a repeat of the pattern for each record? Is there another element that surrounds the repeats perhaps?  What are the names of the fields in your database?


            It may still be calculated, but the whole picture would be helpful.


            Sent from miPhone

            • 3. Re: export to XML

              yes parsing probably most simple.. thanks

              • 4. Re: export to XML
                David Moyer


                in my experience, you can export xml by simply populating a single text field in a single record.  This is because xml doesn't "care" about line-by-line formatting.  Export to .tab format but name your file filename.xml.

                In your one text field, start with <?xml version="1.0" encoding="UTF-8"?> and then add your xml.  In windows, I can double-click my filename.xml and it will open in Internet Explorer which clearly shows if the xml is well formed, or not.

                • 5. Re: export to XML

                  I would simply use export to xml using "FMPRESULTXML" grammar with an XSL-stylesheet.


                  That xsl could in your case look as follows:



                  <?xml version="1.0" encoding="UTF-8"?>
                  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:fmp="http://www.filemaker.com/fmpxmlresult" version="1.0" exclude-result-prefixes="fmp"
                  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
                  <xsl:strip-space elements="*"/>
                  <xsl:template match="fmp:FMPXMLRESULT">
                  <xsl:for-each select="fmp:RESULTSET/fmp:ROW">
                  <xsl:value-of select="fmp:COL[1]/fmp:DATA"/>
                  <xsl:value-of select="fmp:COL[2]/fmp:DATA"/>


                  Just copy and paste this into a text-document (change the extension to xsl) and export to an xml-file using this xsl and the result should look something like:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <stockupdates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


                  XML/XSL is very verbose, but it does not need to be difficult as you can see in the example here.


                  For more info look at XSLT Introduction and XPath Tutorial and XML and XSLT


                  Once I also started with a field and a script and as soon things got a little complicated I also had major problems. So I started learning xslt and never go back to fields and scripts. It is really worth the effort

                  1 of 1 people found this helpful
                  • 6. Re: export to XML

                    caveat: single field, single row export (with Tab-delimited) will still convert your CR (returns) to VT (vertical tab) and tabs to spaces:



                    • 7. Re: export to XML


                      yes I have hit this problem!

                      the xml file when sent to the web hosting company came back with errors says there are VT's in it.


                      is there any easy solution to this, I guess I will have to use a stylesheet but not sure where to start with this and the one Menno posted doesn't seem to work.



                      • 8. Re: export to XML

                        Meeno, is the any chance you can help me with your stylesheet (I agree is the only way to do this now).

                        I used your example and get an error.

                        SAXparse exception, invalid document structure.



                        • 9. Re: export to XML

                          as an alternative, I wrote this article.


                          It has an XSLT to export the single field. However there is a buglet with Windows and XML & XSLT. So I appended the article with a way to push the single field to one field, many records, so that standard tab-separated can be used and avoid the end-of-line problem. You will still have a problem if there are tab characters in the single-field-many-records, as they will not export exactly as in the field. So, there are many plug-ins (even free ones!) that can push your field contents and preserve your characters as you entered them (including the CRLF, if so desired).



                          • 10. Re: export to XML

                            Beverly, thanks for this, I used your stylesheet for a single field export which seems to have worked a treat, also it has worked by using export records (not export field contents) as this is a server script and the later isn't an option.

                            So to do this I just showed any 1 record and exported the global field using your XSL & it looks good.



                            • 11. Re: export to XML

                              This may be a problem caused by data within your export fields. I've cut and pasted Menno's solution and it worked perfectly for the export on my data.

                              • 12. Re: export to XML

                                yes not sure what is going on but I got a solution that seems to work.. fingers crossed.. thanks.