ThePort's Product and Technology blog. We'll share helpful tips about the platform, talk about upcoming releases, and maybe on occasion share a story or two on how awesome the team is here.
Template trick: calling a remote webservice
One handy trick you can take advantage of in our XSLT template system is calling out to a webservice to fetch XML. This can be ANY RSS, ATOM, or XML based publicly available feed out on the web. And it's super easy to use. See the code snippet below:
// Creating a variable that will contain the XML node iterator
<xsl:variable name="oXML" select="iPageInformation:UtilGetXMLFromUrl('your url here')"/>
// Using our show xml construct so we can debug and see the return
<xsl:value-of select="iPageInformation:ShowXML($oXML,'Show XML')" disable-output-escaping="yes"/>
// from here you can treat the return as any other XML node iterator. Loop, XPath, etc.
And it's that simple. One gotcha to be aware of is namespacing. For instance, if the below sample return is namespaced:
<StatusUpdates xmlns="http://services.theport.com">
When this is the case, you have to be sure to declare the namespace in your XSLT like so:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:theport="http://services.theport.com"
And then your XPATH must include the namespace like so:.
<xsl:for-each select="$oXML/theport:StatusUpdates/theport:StatusUpdate">
Hope this helps!