{"id":7956,"date":"2020-05-21T11:36:49","date_gmt":"2020-05-21T18:36:49","guid":{"rendered":"https:\/\/minisoft.com\/support\/?p=7956"},"modified":"2020-07-02T13:29:28","modified_gmt":"2020-07-02T20:29:28","slug":"create-xml-action-in-eformz","status":"publish","type":"post","link":"https:\/\/www.minisoft.com\/support\/create-xml-action-in-eformz\/","title":{"rendered":"Create XML Action in eFORMz"},"content":{"rendered":"\n<p>This document expands on the <a href=\"\/support\/index.php\/create-xml\/\">Create XML post<\/a> by going through a sample eFORMz project. The concepts illustrated by the project also apply to the <a href=\"\/support\/index.php\/record-element\/\">\u201cRecord Element\u201d output type<\/a>.<\/p>\n\n\n\n<p><strong>Sample project: <a href=\"\/support\/wp-content\/uploads\/2020\/05\/CreateXMLRepeatingNode.zip\">CreateXMLRepeatingNode.efz<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create XML with Singleton Variable<\/h2>\n\n\n\n<p>The ArrayVar3 variable is a repeating variable with 3 instances, and SingletonVar is a singleton variable with only one instance.<\/p>\n\n\n\n<p>In the \u201cCreate XML with Singleton Try 1\u201d procedure, we use the \u201cCreate XML\u201d action to create an XML element that repeats on ArrayVar3. Then inside this node, we create two subnodes: ArrayVar3Node to hold the individual values of ArrayVar3, and SingletonVarNode to hold the value of the SingletonVar. We assign the XML thus created to the XMLVersion1 variable.<\/p>\n\n\n\n<p>Inspecting the XMLVersion1 variable, we see the XML only shows the value of the single variable SingletonVar one time, in the first instance of the SingletonVarNode node:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;Root&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;0&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode&gt;SingletonVarValue&lt;\/SingletonVarNode&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;1&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode \/&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;2&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode \/&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&lt;\/Root&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create XML with Repeated Singleton Variable<\/h2>\n\n\n\n<p>If we want the value of the SingletonVar to repeat, we must create a repeating variable and set the value of each instance to the singleton value. This is illustrated by the procedures \u201cCreate Variable that repeats the Singleton Value\u201d and \u201cInitialize SingletonVarRepeating\u201d. The former uses the \u201cLoad Variable from Variable\u201d action to create a repeating variable, SingletonVarRepeating, that has the same number of instances as the ArrayVar3 variable. Then the latter procedure loops through that variable, setting each instance to the singleton value \u201cSingletonVarValue\u201d.<\/p>\n\n\n\n<p>Finally, the procedure \u201cCreate XML with Singleton Try 2\u201d uses the Create XML action to create XML where both the array variable and the singleton variable have their values repeated in all the repeating elements. This XML is saved in the variable XMLVersion2, shown here:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;Root&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;0&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode&gt;SingletonVarValue&lt;\/SingletonVarNode&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;1&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode&gt;SingletonVarValue&lt;\/SingletonVarNode&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&nbsp; &lt;RepeatingNode&gt;\n&nbsp;&nbsp;&nbsp; &lt;ArrayVar3Node&gt;2&lt;\/ArrayVar3Node&gt;\n&nbsp;&nbsp;&nbsp; &lt;SingletonVarNode&gt;SingletonVarValue&lt;\/SingletonVarNode&gt;\n&nbsp; &lt;\/RepeatingNode&gt;\n&lt;\/Root&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Record Element with XML Content<\/h2>\n\n\n\n<p>The Record Element output is created with a root node \u201cRoot\u201d and two child nodes \u201cBadNode\u201d and \u201cGoodNode\u201d. We set the value of the BadNode node with the contents of the variable XMLVersion1, indicating in the \u201cElement Content\u201d dialog that the format should be \u201cXML\u201d and to \u201cOmit root\u201d:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"376\" height=\"250\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1.png\" alt=\"\" class=\"wp-image-7957\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1.png 376w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1-300x199.png 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1-150x100.png 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1-250x166.png 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml1-271x180.png 271w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/figure>\n\n\n\n<p>This demonstrates how we can take an existing XML string and add it into either Create XML or Record Element as the value of a node, effectively grafting the XML represented by that XML string into the XML structure.<br>Similarly, we set the value of the GoodNode node with the contents of the variable XMLVersion2:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"376\" height=\"250\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2.png\" alt=\"\" class=\"wp-image-7958\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2.png 376w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2-300x199.png 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2-150x100.png 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2-250x166.png 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml2-271x180.png 271w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Examining Output XML<\/h2>\n\n\n\n<p>The contents of the Record Element are displayed in the Viewer window, so you can see that in the \u201cBadNode\u201d the singleton variable value is only shown in the first instance of the RepeatingNode, while in the \u201cGoodNode\u201d the singleton variable value is shown in all the instances:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"408\" height=\"424\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3.png\" alt=\"\" class=\"wp-image-7959\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3.png 408w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3-289x300.png 289w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3-144x150.png 144w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3-250x260.png 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/05\/create_xml3-173x180.png 173w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This document expands on the Create XML post by going through a sample eFORMz project. The concepts illustrated by the project also apply to the \u201cRecord Element\u201d output type. Sample project: CreateXMLRepeatingNode.efz Create XML with Singleton Variable The ArrayVar3 variable is a repeating variable with 3 instances, and SingletonVar is a singleton variable with only [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[132],"_links":{"self":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7956"}],"collection":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=7956"}],"version-history":[{"count":4,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7956\/revisions"}],"predecessor-version":[{"id":7966,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7956\/revisions\/7966"}],"wp:attachment":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=7956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=7956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=7956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}