June 28, 20214 yr Hi I'm trying to import xml data into several fields using Insert From URL. I can get it to all appear in one field but I need it to be distributed into several. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <MACHINE Generated="2021-06-28T14:19:20+01:00" device="Boris"> <IDLE>TRUE</IDLE> <IP>172.16.3.202</IP> <QUEUELENGTH>11</QUEUELENGTH> <TIME unit="sec">9780</TIME> </MACHINE> Is there a way to populate the following fields from tagging onto to my Insert From URL script. MACHINE, IDLE, IP, QUEUELENGTH & TIME I can save the xml into a file and import that way using a .xsl file but I wanted to do this all in one script.
June 28, 20214 yr 16 minutes ago, Plucky said: I can save the xml into a file and import that way using a .xsl file You can import an XML file directly from a URL. Going through Insert From URL does not achieve anything useful.
June 28, 20214 yr Author Hi I thought I had to use an Insert from URL, Just added the link to the HTTP request window in the Import Records script step and that's worked fine. I'm ok with importing elements but how can I import the the 2 x attributes. <?xml version="1.0" encoding="UTF-8" standalone="no"?><MACHINE Generated="2021-06-28T15:16:06+01:00" device="Boris"><IDLE>FALSE</IDLE><IP>172.16.3.202</IP><QUEUELENGTH>14</QUEUELENGTH><TIME unit="sec">12419</TIME></MACHINE> <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="/MACHINE"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <!-- Job Fields --> <FIELD NAME="IDLE"/> <FIELD NAME="IP"/> <FIELD NAME="QUEUELENGTH"/> <FIELD NAME="TIME"/> <!-- define more fields here --> </METADATA> <!-- IMPORT DATA --> <RESULTSET> <xsl:for-each select="MACHINE"/> <ROW> <!-- JOB data --> <COL><DATA><xsl:value-of select="IDLE"/></DATA></COL> <COL><DATA><xsl:value-of select="IP"/></DATA></COL> <COL><DATA><xsl:value-of select="QUEUELENGTH"/></DATA></COL> <COL><DATA><xsl:value-of select="TIME"/></DATA></COL> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet>
June 28, 20214 yr 28 minutes ago, Plucky said: how can I import the the 2 x attributes Start by adding the target field names to the METADATA section. Then add a COL for each attribute, using the @ symbol to select the attribute: <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="/MACHINE"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD NAME="IDLE"/> <FIELD NAME="IP"/> <FIELD NAME="QUEUELENGTH"/> <FIELD NAME="TIME"/> <FIELD NAME="Generated"/> <FIELD NAME="Device"/> </METADATA> <RESULTSET> <ROW> <COL><DATA><xsl:value-of select="IDLE"/></DATA></COL> <COL><DATA><xsl:value-of select="IP"/></DATA></COL> <COL><DATA><xsl:value-of select="QUEUELENGTH"/></DATA></COL> <COL><DATA><xsl:value-of select="TIME"/></DATA></COL> <COL><DATA><xsl:value-of select="@Generated"/></DATA></COL> <COL><DATA><xsl:value-of select="@device"/></DATA></COL> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> Note that I have removed your <xsl:for-each select="MACHINE"/> instruction which - being empty - does nothing and wouldn't do anything even if weren't empty: your template puts you in the context of the root element MACHINE and this element has no child MACHINE elements.
Create an account or sign in to comment