{"id":249,"date":"2011-09-24T14:58:53","date_gmt":"2011-09-24T14:58:53","guid":{"rendered":"https:\/\/www.harepoint.com\/Blog\/?p=249"},"modified":"2021-08-11T11:08:30","modified_gmt":"2021-08-11T11:08:30","slug":"xml-in-sharepoint-workflow","status":"publish","type":"post","link":"https:\/\/www.harepoint.com\/Blog\/xml-in-sharepoint-workflow\/","title":{"rendered":"How to download and process XML file in SharePoint Workflow"},"content":{"rendered":"\n<p>This workflow example shows you how to get data from an XML file. We will download the XML with currency exchange rates from the <a href=\"https:\/\/www.ecb.europa.eu\/home\/html\/index.en.html\" target=\"_blank\" rel=\"nofollow\">European Central Bank<\/a> and get a list of currencies and their exchange rates. We will convert this information into HTML and save it in Shared Documents. To create this workflow, we will use both SharePoint workflow components and components included in <a href=\"\/Products\/SharePoint-Workflows\/Default.aspx\">HarePoint Workflow Extensions<\/a>, because it is impossible to perform some of the actions needed using SharePoint Workflow components alone:<\/p>\n\n<table border=\"1\" cellpadding=\"5\" style=\"border-style: solid; border-collapse: collapse; border-spacing: 0px;\">\n    <tbody>\n        <tr>\n            <td rowspan=\"2\"><b>Component name and type<\/b><\/td>\n            <td align=\"center\" colspan=\"2\"><b>Set of Workflow components<\/b><\/td>\n        <\/tr>\n        <tr>\n            <td align=\"center\"><b>SharePoint Workflow<\/b><\/td>\n            <td align=\"center\"><b>HarePoint Workflow Extensions<\/b><\/td>\n        <\/tr>\n        <tr>\n            <td>Send HTTP GET Request (action)<\/td>\n            <td><\/td>\n            <td align=\"center\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n        <\/tr>\n        <tr>\n            <td>If any value equals value (condition)<\/td>\n            <td align=\"center\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n            <td><\/td>\n        <\/tr>\n        <tr>\n            <td>Transform XML (action)<\/td>\n            <td><\/td>\n            <td align=\"center\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n        <\/tr>\n        <tr>\n            <td>Create document from Text (action)<\/td>\n            <td><\/td>\n            <td align=\"center\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n        <\/tr>\n    <\/tbody>\n<\/table>\n<p><b>The Workflow will work in the following manner:<\/b><\/p>\n<ul>\n    <li>Download the XML file with currency exchange rates: https:\/\/www.ecb.europa.eu\/stats\/eurofxref\/eurofxref-daily.xml<\/li>\n    <li>Convert XML data into HTML<\/li>\n    <li>Save the HTML data as a new document in Shared Documents on SharePoint<\/li>\n<\/ul>\n<p><b>Let&#8217;s start creation of the Workflow.<\/b><\/p>\n<p>1. Start SharePoint Designer, open the site, point to \u201cWorkflows\u201d, click the \u201cSite Workflow\u201d button on the ribbon and type the name of the Workflow. Click OK. An empty workflow is now created.<\/p>\n<p>2. Use the <b>Send HTTP GET Request<\/b> action from the <a href=\"\/Products\/HarePointWorkflowExtensions\/Network-SharePoint-Workflow-Action.aspx\">HarePoint Activities \u2013 Network<\/a> activity group:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-1.png\"><\/p>\n<p>This action allows us to download the required XML file.<\/p>\n<p>Use the XML file URL the first parameter:<\/p>\n<img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-2.png\">\n<p>Leave the second parameter unchanged and set two variables:<\/p>\n<ul>\n    <li><b>response<\/b> with received XML data<\/li>\n    <li><b>statusCode<\/b> to store HTTP response status code<\/li>\n<\/ul>\n<p>The configured action looks like this:<\/p>\n<p><a href=\"\/Pictures\/Workflow\/example-xml-3.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-3.png\"><\/a><\/p>\n<p>3. Now we should check the value in the <b>statusCode<\/b> variable to be sure that the data is received. If the requested data is received, this variable contains the value equal to <i>200<\/i>. To verify the value of the variable we will use the condition <b>If any value equals value<\/b>. Select the variable as the first parameter and type <i>200<\/i> as the second one:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-4.png\"><\/p>\n<p>4. Now we should transform the received XML file to HTML. We can do that using the <b>Transform XML<\/b> action which is located in the <a href=\"\/Products\/HarePointWorkflowExtensions\/Development-SharePoint-Workflow-Action.aspx\">HarePoint Activities \u2013 Development<\/a> activities category.<\/p>\n<p>Select the <b>response<\/b> variable as the first parameter in this action.<\/p>\n<p>The second parameter should include an XSLT request which transforms XML data into HTML. In our example this request looks like this:<\/p>\n<pre>&lt;xsl:stylesheet version=\"1.0\"\nxmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"\nxmlns:gesmes=\"http:\/\/www.gesmes.org\/xml\/2002-08-01\"\nxmlns:cubes=\"http:\/\/www.ecb.int\/vocabulary\/2002-08-01\/eurofxref\"&gt;\n&lt;xsl:template match=\"\/\"&gt;\n&lt;html&gt;\n&lt;body&gt;\n&lt;table border=\"1\"&gt;\n&lt;tr bgcolor=\"#9acd32\"&gt;\n&lt;th&gt;Currency&lt;\/th&gt;\n&lt;th&gt;Rate&lt;\/th&gt;\n&lt;\/tr&gt;\n&lt;xsl:for-each select=\"\/\/cubes:Cube\/cubes:Cube\/cubes:Cube\"&gt;\n&lt;tr&gt;\n&lt;td&gt;&lt;xsl:value-of select=\"@currency\"\/&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;xsl:value-of select=\"@rate\"\/&gt;&lt;\/td&gt;\n&lt;\/tr&gt;\n&lt;\/xsl:for-each&gt;\n&lt;\/table&gt;\n&lt;xsl:value-of select=\"\/\/gesmes:name\"\/&gt;: &lt;xsl:value-of select=\"\/\/cubes:Cube\/@time\" \/&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n&lt;\/xsl:template&gt;\n&lt;\/xsl:stylesheet&gt;<\/pre>\n<p>The third parameter is the variable in which the HTML code will be saved. When this action is configured it looks like this:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-5.png\"><\/p>\n<p>5. Finally, we can save the HTML code into the file. To do that, we should use the <b>Create document from Text<\/b> action which is located in <a href=\"\/Products\/HarePointWorkflowExtensions\/Document-Library-SharePoint-Workflow-Action.aspx\">HarePoint activities \u2013 Document Library<\/a> activities category.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-6.png\"><\/p>\n<p>The first parameter is the variable which contains HTML data.<\/p>\n<p>The second parameter is location of the file which should be created. It should also contain a filename. For example: <i>YOUR_SITE\/Shared%20Documents\/Rates.aspx<\/i><\/p>\n<p>Set the \u201coverwrite\u201d option in the third parameter to overwrite the existing file each time the workflow is started.<\/p>\n<p>The workflow is ready. It looks like this:<\/p>\n<p><a href=\"\/Pictures\/Workflow\/example-xml-7.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-7.png\"><\/a><\/p>\n<p>Save and Publish the Workflow.\n<p>Now, let&#8217;s test the Workflow. Open the site where the workflow was published; point to the page \u201cAll site content\u201d and click \u201cSite workflows\u201d. Locate your workflow and click on it. Click the \u201cStart\u201d button to execute the workflow. Look at the list called \u201cMy completed workflows\u201d and make sure that your workflow has the status \u201cCompleted\u201d and that the time of the workflow Start and End is real. Now you can point to Shared Documents and open the file Rates.aspx which was created by the workflow. Verify that the data is displayed properly.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-9.png\"><\/p>\n<p>We created a workflow which gets data from a XML file and generates a new page, but you can also create a simple web-part which displays the data on the web part`s page.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-xml-10.png\"><\/p>\n<p>You can also watch the whole process of creating such a workflow in this video:<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/iqRPBygfY9o\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe><\/p>\n<hr>\n<p>Learn more about <a href=\"\/Products\/HarePointWorkflowExtensions\/Default.aspx\">HarePoint Workflow Extensions<\/a> and over 300 new actions to automate any business process without programming.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This workflow example shows you how to get data from an XML file. We will download the XML with currency exchange rates from European Central Bank, get a list of currencies and their exchange rates. We will convert this information into HTML and save in Shared Documents. To create such a workflow we will use both SharePoint workflow components and the components added by HarePoint Workflow Extensions, because it is impossible to prepare such a workflow using merely its own SharePoint Workflow components.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[25,17],"_links":{"self":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/249"}],"collection":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":23,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":2517,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/249\/revisions\/2517"}],"wp:attachment":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}