xslt - Stuck Campaign Monitor XML into FileMaker -
i'm trying import export campaign monitor api filemaker stuck getting xslt work custom fields.
i'm trying key values of id , mr_or_mrs.
i think need key function whatever i've tried hasn't worked.
xml:
<pagedresult> <numberofpages>1</numberofpages> <orderdirection>asc</orderdirection> <pagenumber>1</pagenumber> <pagesize>1000</pagesize> <recordsonthispage>439</recordsonthispage> <results> <subscriber> <customfields> <customfield> <key>[mr_or_mrs]</key> <value>mrs_email</value> </customfield> <customfield> <key>[id]</key> <value>abcef1234</value> </customfield> </customfields> <date>2015-06-15 17:40:00</date> <emailaddress>mrssmith@email.com</emailaddress> <name>mrs smith</name> <readsemailwith/> <state>active</state> </subscriber> <subscriber> <customfields> <customfield> <key>[mr_or_mrs]</key> <value>mr_email</value> </customfield> <customfield> <key>[id]</key> <value>1234567890</value> </customfield> </customfields> <date>2015-06-15 17:40:00</date> <emailaddress>jones@gmail.com</emailaddress> <name>mr jones</name> <readsemailwith/> <state>active</state> </subscriber>
xslt:
<?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 name="id" type="text"/> <field name="name" type="text"/> <field name="email" type="text"/> <field name="mr_mrs" type="text"/> </metadata> <resultset> <xsl:for-each select="pagedresult/results/subscriber"> <row> <col> <data>*this i'm stuck*</data> </col> <col> <data><xsl:value-of select="name/text()"/></data> </col> <col> <data><xsl:value-of select="emailaddress/text()"/></data> </col> <col> <data>*this i'm stuck*</data> </col> </row> </xsl:for-each> </resultset> </fmpxmlresult> </xsl:template> </xsl:stylesheet>
desired output:
<?xml version="1.0" encoding="utf-8"?> <fmpxmlresult xmlns="http://www.filemaker.com/fmpxmlresult"> <metadata> <field type="text" name="id" /> <field type="text" name="name" /> <field type="text" name="email" /> <field type="text" name="mr_mrs" /> </metadata> <resultset> <row> <col> <data>abcef1234</data> </col> <col> <data>mrs smith</data> </col> <col> <data>mrssmith@email.com</data> </col> <col> <data>mrs_email</data> </col> </row> <row> <col> <data>1234567890</data> </col> <col> <data>mr jones</data> </col> <col> <data>jones@gmail.com</data> </col> <col> <data>mr_email</data> </col> </row> </resultset> </fmpxmlresult>
any appreciated.
i think need key function
not really. try:
<xsl:template match="/"> <fmpxmlresult xmlns="http://www.filemaker.com/fmpxmlresult"> <metadata> <field name="id" type="text"/> <field name="name" type="text"/> <field name="email" type="text"/> <field name="mr_mrs" type="text"/> </metadata> <resultset> <xsl:for-each select="pagedresult/results/subscriber"> <row> <col> <data> <xsl:value-of select="customfields/customfield[key='[id]']/value"/> </data> </col> <col> <data><xsl:value-of select="name"/></data> </col> <col> <data><xsl:value-of select="emailaddress"/></data> </col> <col> <data> <xsl:value-of select="customfields/customfield[key='[mr_or_mrs]']/value"/> </data> </col> </row> </xsl:for-each> </resultset> </fmpxmlresult> </xsl:template>
Comments
Post a Comment