{"id":32247,"date":"2022-12-12T18:23:22","date_gmt":"2022-12-12T18:23:22","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32247"},"modified":"2022-12-23T05:44:34","modified_gmt":"2022-12-23T05:44:34","slug":"octopus-deploy-tutorials-transform-xml-file-using-structured-configuration-variables","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/octopus-deploy-tutorials-transform-xml-file-using-structured-configuration-variables\/","title":{"rendered":"Octopus Deploy Tutorials: Transform XML file using Structured configuration variables"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How it works?<\/h2>\n\n\n\n<p>For XML files, the values to replace are located using the standard XPath syntax. Octopus supports both XPath 1 and XPath 2.<\/p>\n\n\n\n<p>Octopus variables with names that are valid XPath expressions are matched against the target XML files. For example, if you have a variable called \/\/environment with the value production, it will replace the contents of all elements with production.<\/p>\n\n\n\n<p>Read &#8211; <a href=\"https:\/\/www.w3schools.com\/xml\/xpath_syntax.asp\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.w3schools.com\/xml\/xpath_syntax.asp<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; To enable Structured Configuration Variables on a step that supports the feature, click the CONFIGURE FEATURES link, select Structured Configuration Variables, then click OK.<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; In the Structured Configuration Variables section of the step, specify the relative paths to your structured configuration files, relative to the working directory. For instance:<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"675\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-15-1024x675.png\" alt=\"\" class=\"wp-image-32248\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-15-1024x675.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-15-300x198.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-15-768x507.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-15.png 1125w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"replacing-content\"><br>Replacing content<\/h3>\n\n\n\n<p>When replacing content, the replacement can only be as rich as what was originally there. If you select an element that contains only text, the replacement will be treated as text and structure-defining characters will be encoded as entity references. However, if you select an element that contains further element structures, the replacement is treated as an XML fragment, and structure-defining characters will be added as is.<\/p>\n\n\n\n<p>This means that if you replace a password or connection string, any characters like\u00a0<code>&amp;<\/code>,\u00a0<code>&lt;<\/code>\u00a0and\u00a0<code>><\/code>\u00a0will be safely encoded within the string. For example, assume the target file contains the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"840\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-16.png\" alt=\"\" class=\"wp-image-32249\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-16.png 916w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-16-300x275.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/12\/image-16-768x704.png 768w\" sizes=\"auto, (max-width: 916px) 100vw, 916px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>How it works? For XML files, the values to replace are located using the standard XPath syntax. Octopus supports both XPath 1 and XPath 2. Octopus variables with names that are valid XPath expressions are matched against the target XML files. For example, if you have a variable called \/\/environment with the value production, it&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-32247","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32247"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32247\/revisions"}],"predecessor-version":[{"id":32250,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32247\/revisions\/32250"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}