Display InfoPath form data in the XML web part


I recently was working on a proof-of-concept where we wanted a team site to display on the default.aspx page some of the data that existed in an InfoPath form. This data needed to be seen by everyone without requiring them to open up the form file. We also wanted to make sure that if the data in the InfoPath form changed, the site reflected that. You might think that we broke down and wrote some custom code. You would of course be wrong. It turns out that we could easily leverage the out-of-the-box XML web part!


The XML web part is pretty simple to use. For my site, I simply used the XML Link property and pointed it to the saved InfoPath form "shared documents/test2.xml". Once connected to the file, it is a rather simple XSLT that can be used to retrieve the data. Here is my XSLT:


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:s0="http://www.sourcecode.co.za/webservices/InfoPathService" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-11-03T22:41:52" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us" >
<xsl:output method="html"/>
<xsl:template match="/">
Title: <xsl:value-of select='//my:DV' /><br/>
Date of Visit: <xsl:value-of select='//my:ETA' /><br/>
City: <xsl:value-of select='//my:City' /><br/>
Country: <xsl:value-of select='//my:Country' /><br/>
Trip Code: <xsl:value-of select='//my:TripCode' /><br/>
WPR: <xsl:value-of select='//my:WPR' />


</xsl:template>
 
</xsl:stylesheet>


The result is a few properties our of the InfoPath form with <br> tags after each item! Have fun.

Skip to main content