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.
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
yes parsing probably most simple.. thanks
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.
1 of 1 people found this helpful
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"?>
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"/>
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"?>
XML/XSL is very verbose, but it does not need to be difficult as you can see in the example here.
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
caveat: single field, single row export (with Tab-delimited) will still convert your CR (returns) to VT (vertical tab) and tabs to spaces:
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.
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.
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).
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.
yes not sure what is going on but I got a solution that seems to work.. fingers crossed.. thanks.