Checking out the interwebs the other day and came across this great blog post by my buddy John Liu (@johnnliu) | Twitter John and the group he works with have done some amazing SharePoint and Nintex work over the years.. Anyway..... He posted about something that I had come across a few times myself over the past few years, so in the interest in sharing, I got John's permission to report the info here for everyone knowledge..
Problem:
You call an XML web service with Nintex Web Service or Web Request actions. You get back a lot of XML, and it is very difficult to work with the namespaces getting in your way.
Solution:
1. Do a quick XSLT post processing in the action, remove all the namespaces with XSLT transform.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@* | node()" /> </xsl:element> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:template> <xsl:template match="text() | comment() | processing-instruction()"> <xsl:copy /> </xsl:template> </xsl:stylesheet>
2. Force top level XML node.
This ensures if your service returns multiple top level elements they get wrapped together.
3. Use XPath in Query XML Action like this:
/xml/Results/Result/Title
Sometimes, after you've wasted half a day working with XML, you just want the simple, no frills, just make it work version.
This will hopefully help you too.
Big thanks to Jumpei Yamauchi for helping me with this one.