蜜豆视频

XML

The XML app enables you to parse an XML formatted text via the XML > Parse XML module and convert it to a bundle to make the data available to other modules. You can also convert a bundle to an XML formatted text via the XML > Create XML module

Access requirements

You must have the following access to use the functionality in this article:

蜜豆视频 Workfront plan*
Pro or higher
蜜豆视频 Workfront license*
Plan, Work
蜜豆视频 Workfront Fusion license**

Current license requirement: No Workfront Fusion license requirement.

Or

Legacy license requirement: Workfront Fusion for Work Automation and Integration

Product

Current product requirement: If you have the Select or Prime 蜜豆视频 Workfront plan, your organization must purchase 蜜豆视频 Workfront Fusion as well as 蜜豆视频 Workfront to use functionality described in this article. Workfront Fusion is included in the Ultimate Workfront plan.

Or

Legacy product requirement: Your organization must purchase 蜜豆视频 Workfront Fusion as well as 蜜豆视频 Workfront to use functionality described in this article.

To find out what plan, license type, or access you have, contact your Workfront administrator.

For information on 蜜豆视频 Workfront Fusion licenses, see 蜜豆视频 Workfront Fusion licenses.

Parse XML

The XML > Parse XML module parses an XML formatted text and outputs a single bundle containing all the information extracted from the XML.

Data structure

The data structure describes the structure of the XML to make the output of the module available in the mapping panel for the following modules.

If you have a sample of the XML you would like to parse, you can use it to generate the data structure:

  1. Click the Add button.

  2. Click the Generator button.

  3. Copy and paste the XML sample into the Sample data field.

  4. Click Save.

  5. Verify that the data structure has been successfully generated.

  6. Click the Save button to save the data structure.

    You can skip the steps 2-5 to supply an empty data structure. If the data structure is empty, the output of the module is not available in the mapping panel until the module has been executed at least once.

For more information, see Data structures in 蜜豆视频 Workfront Fusion.

Preserve numbers as text
Enable this option to ensure that numbers remain as text (string) values. Otherwise, numbers are cast to number values.
XML

Enter or map the XML formatted text you would like to parse.

If you use a formula, make sure its result value type is (or can be automatically coerced to) the Text data type.

If the result value type is Buffer (binary data) then use the toString() function to convert it to the Text data type. For more information, see Type coercion in 蜜豆视频 Workfront Fusion and Item data types in 蜜豆视频 Workfront Fusion.

INFO
Example: To download an XML file from a URL and parse its content:
  1. Create a new scenario.

  2. Insert HTTP > Get a file module

  3. Open the module鈥檚 configuration and configure it as follows:

    URL: URL of the XML file (e.g. https://siftrss.com/f/rqLy05ayMBJ)

  4. Click OK 鈥媡o save and close the module鈥檚 configuration.

  5. Add XML > Parse XML module, connect it after the HTTP > Get a file module and configure it as follows:

    table 0-row-2 1-row-2 layout-auto html-authored no-header
    Data structure
    1. Click the Add button.
    2. Click the Generator button.
    3. In your web browser, open a new tab or window.
    4. Put the URL you used in the third step in the address bar and fetch the XML file.
    5. Select all the XML text and copy it into the clipboard.
    6. Close the tab or window and get back to your scenario.
    7. Paste the copied XML text into the Sample data field.
    8. Click Save.
    9. Verify that the data structure has been successfully generated.
    10. Click Save to save the data structure.

    You can skip steps 2 through 9 to supply an empty data structure. If the data structure is empty, the output of the module is not available in the mapping panel until the module has been executed at least once.

    XML

    Map the Data item from the output of the HTTP > Get a file module into the field. Use the toString() function to convert its value from the Buffer (binary data) type to Text data type.

    You may copy and paste the formula's code into the field: {{toString(1.data)}}

    For more information the Buffer and Text data types, see Item data types in 蜜豆视频 Workfront Fusion.

Parsing XML attributes

By default, the XML > Parse XML module puts attributes in a special collection _attributes as a child of the node that has these attributes. If the node is a text node and it has attributes, then two special properties are added: _attributes for attributes and _value for the text content of the node.

INFO
Example: This XML:
<root attr="1">
<node attr="ABC">Hello, World</node>
</root>

is converted into this bundle:

Create XML

The XML > Create XML module converts a bundle to an XML formatted text.

Data structure

The Data structure describes the structure of the resulting XML. If you have a sample of the XML you would like to create, you can use it to generate the data structure:

  1. Click the Add button.
  2. Click the Generator button.
  3. Copy and paste the XML sample into the Sample data field.
  4. Click the Save button.
  5. Verify that the data structure has been successfully generated.
  6. Click Save to save the data structure.
Root element name
Enter the name of the XML's root element. The default value is root.
Doctype SYSTEM ID
Enter the file name to use in the !DOCTYPE SYSTEM declaration
Doctype PUBLIC ID
Enter the file name to use in the !DOCTYPE PUBLIC declaration
Strip Xml Declaration
Enable this option to remove the XML Declaration <?xml ... ?> and <!DOCTYPE ... >and leave only the XML root element and its contents.
INFO
Example:
A typical use case is to transform data from a Google >spreadsheet into XML.
  1. Place the Google Sheets > Select rows module in your scenario to fetch the data. Set up the module to retrieve rows from your Google spreadsheet. Set the鈥 Maximum number of returned rows to a small number, but larger than one for testing purposes (Example, three). Execute the Google Sheets module by right-clicking it and choosing 鈥Run this module only.鈥 Verify the output of the module.

  2. Connect the Array Aggregator module after the Google Sheets module. In the module鈥檚 setup choose the Google Sheets module in the Source node field. Leave the other fields as they are for the moment.

  3. Connect the XML > Create XML module after the Array Aggregator module.

    The module鈥檚 setup requires a data structure that describes the structure of the XML output. Click the Add button to open the data structure setup. The easiest way to create this data structure is to generate it automatically from an XML sample.

  4. Click the Generator button and paste your XML sample to the Sample data field:

  5. Click Save. The Specification field in the Data structure now contains the generated structure.

  6. Change the name of your Data structure to something more specific and click Save. A field corresponding to the root array attribute appears as a mappable field in the JSON module鈥檚 setup.

  7. Click the Map button next to the field and map the Array[] item from the Array aggregator output to it:

  8. Click OK to close the XML module鈥檚 setup.

  9. Open the setup of the Array Aggregator module. Change the Target structure from Custom to an XML module鈥檚 field corresponding to the parent XML element.Map items from the Google Sheets module to the appropriate fields.

  10. Click OK to close the Array Aggregator module鈥檚 setup.

  11. Run the scenario.

    The XML module outputs the correct XML file.

  12. Open the setup of the Google Sheets module and increase the Maximum number of returned rows number to be larger than the number of rows in your spreadsheet to process all the data.

    The resulting XML can be saved to Dropbox, sent as an attachment via email, uploaded via FTP to a server, and so on.

Adding XML attributes

If you want to add attributes to a complex node (a node that will contain other nodes), you must add a collection with the name _attributes for the complex note in your custom data structure. This collection will be mapped to node attributes. If you want to add attributes to a text node (for example: <node attr="1">abc</node>), you must add a collection _attributes for attributes and a text property _value for the node value for this node in your custom data structure.

{
   "name": "node",
   "type": "collection",
   "spec": [
      {
         "name": "_attributes",
         "type": "collection"
         "spec": [
            {
               "name": "attr1",
               "type": "text"
            }
         ]
      },
      {
         "name": "_value",
         "type": "text"
      }
   ]
}

Troubleshooting: Cannot map data from the Parse XML module

Make sure the data structure is defined correctly. Alternatively, you may use an empty data structure and execute the module at least once to process an XML input.

recommendation-more-help
5f00cc6b-2202-40d6-bcd0-3ee0c2316b43