Flow Connect Help
Roadmap
  • ℹ️This is Flow Connect
    • Overview
    • Technical overview
      • System requirements
    • What's new?
      • Change log
  • ▶️quick start
    • Create an application
    • Create an admin access group
  • 🔁working with Connect
    • Connect to systems
      • Connector agents
        • Add agent group
        • Install agent manager
        • Add agent
        • Manage agent
      • Connectors
        • IFS Applications 10
        • Oracle
        • Microsoft SQL Server
        • Send Email
        • REST
          • Microsoft Graph API
          • Infor M3 REST
            • Obtaining Infor ION API file
            • Configure REST Connector with ION API file
          • IFS Cloud
            • IAM Client Registration
            • Obtaining end-point info from IFS Cloud
            • Configure REST Connector for IFS Cloud
        • File System
      • Redirect URIs
    • Create and design
      • Application packages
      • Applications
        • Create
        • Design
        • Test
        • Commit
      • Portal Pages
        • Create Portal Page
        • Design Portal Page
        • Commit Portal Page
      • Components
        • Create component
        • Manage component
      • Modules
        • Create module
        • Manage module
      • Automations
        • Functionality
        • Create Automation
        • Manage Automation
        • Creating Access Key
        • Executing Automations Externally
          • IFS Cloud
          • Salesforce Apex Trigger Example
    • Deploy
      • Environments
      • Deploy
    • Use
      • On mobile devices
      • In web browser - Web client
      • In web browser - Portal
    • Share
      • Share Applications
    • User administration
      • Users
        • Invite a new user
        • Manage users
      • User groups
        • Create user groups
        • Manage user groups
      • Access
        • Manage access
  • ⏸️Reference
    • How-to guides
      • Create User Step controls
        • Header
        • Static text
        • Labelled static text
        • Link
        • Image viewer
        • Text input
        • Numeric input
        • Date input
        • Time input
        • Check box input
        • Binary option input
        • List selection input
        • List multi-selection input
        • Menu selection input
        • Data grid
        • Calendar control
        • Image selection input
        • List presentation
        • Camera Input
      • Dependent controls in User step
        • Variable source
        • Expression source
        • Control visibility (condition to hide)
      • Configure SSO for Microsoft Entra
    • Reference
      • Clients
        • Settings
        • My data
      • Designer
        • Controls
          • Header
          • Static text
          • Labeled static text
          • Link
          • External app launcher
          • Image viewer
          • Text input
          • Numeric input
          • Date input
          • Time input
          • Check box input
          • Binary option input
          • List selection input
          • List multi-selection input
          • Menu selection input
          • Data grid
          • Calendar
          • Image selection input
          • List presentation
          • Camera input
          • File gallery
          • GPS location input
          • Signature capture input
          • Item creation sub task
          • Check list sub task
          • Verb sub task
        • Steps
          • Start
          • User interaction
          • External system
          • Decision
          • Assertion
          • HTTP requests
          • Assignment
          • Table
          • Event listener
          • Checkpoint
          • Script
          • Annotation
          • End
          • Local data resource
      • Portal
        • Design items
          • Portlets
            • Accumulation chart
            • Base chart
            • Circular gauge
            • Custom content
            • Data tree
            • Document viewer
            • Filter
            • Kanban
            • KPI card
            • Link
            • My apps
            • Record
            • Rich text
            • Table
          • Container
          • Common portlet configuration
            • General
            • Events
            • Data
            • Custom buttons
            • Style
        • Portal settings
          • Branding
          • Page
          • Navigation
        • Profile
        • Portlet actions
        • Cache
        • Input to Start Step
      • Diagnostic mode
      • FlowScript
        • Walkthrough
          • Introduction
          • Expressions and programs
          • Anatomy of a program
          • Variables
          • Simple types
          • Nullable types
          • Records
          • Sequences
          • Other types
          • Arithmetic
          • Other expressions
          • Queries
          • Conditionals and loops
          • Function definitions
          • Built-in functions
          • DateTime module
          • Seq module
          • HTTP module
          • CSV module
          • JSON module
          • Trace module
          • Record module
          • XML Module
          • Filesystem Module
          • Custom modules
          • Custom Types
          • Appendix: Subtyping rules
          • Appendix: Escape sequences
          • Appendix: Type checking errors
      • Flowscript Copilot
      • Glossary
    • Flow Connect Downloads
      • Install Flow Connect Designer
    • Migrate from Flow Classic
      • Portal - migrate from Flow Classic
      • Classic vs. Connect Comparison Guide
Powered by GitBook
On this page
  • Examples
  • Reading an XML document
  • Creating an XML document
  • Types
  • Functions
  • Functions for reading XML
  • Functions for creating XML

Was this helpful?

  1. Reference
  2. Reference
  3. FlowScript
  4. Walkthrough

XML Module

You can use the XML module to read or write XML data. XML documents are represented as a DOM (Document Object Model) struture.

Examples

Reading an XML document

// Read an example document and extract information from it.

open XML;
open Seq;

let data = `<items>
                <item id="001">
                    <name>Apple (Cox Pomona)</name>
                </item>

                <item id="002">
                    <name>Apple (Ingrid Marie)</name>
                </item>

                <item id="003">
                    <name>Orange (Valencia)</name>
                </item>
            </items>`;

// Use the 'parse' function to turn the text into an XML DOM document.
let doc = parse(data);

// For each child element of the document root (i.e. for each <item> element),
// map that into a record containing the value of the "id" attribute
// and the value of the <name> child element.
return doc.root
          .getChildren()
          .map(e => {
            id: e.getNamedAttribute("id").value,
            name: e.getNamedChild("name").value 
           });
  
// The resulting FlowScript sequence will look like this:
// [
//    {
//        id: "001",
//        name: "Apple (Cox Pomona)"
//    },
//    {
//        id: "002",
//        name: "Apple (Ingrid Marie)"
//    },
//    {
//        id: "003",
//        name: "Orange (Valencia)"
//    }
// ] 

Creating an XML document

// Use the document, element and attribute functions to create an XML document.

open XML;

let xmlns = "http://www.w3.org/2000/xmlns/";
let myNamespace = "http://example.org/schema/my-schema.xsd";

let doc = document(
    element("Document",
        attribute(qualifiedName(xmlns, "test"), myNamespace),
        element("Messages",
            element("Message", "Hello world"),
            element("Message", "Good bye")
        ),
        element(qualifiedName(myNamespace, "Item"), "Namespaced")
    )
);

return print(doc);

// The resulting text will look like this:
//
// <Document xmlns:test="http://example.org/schema/my-schema.xsd">
//  <Messages>
//    <Message>Hello world</Message>
//    <Message>Good bye</Message>
//  </Messages>
//  <test:Item>Namespaced</test:Item>
// </Document>

Types

QName

Represents a qualified name with an optional namespace.

type QName = { namespace: text?, localName: text };

Attribute

Represents an XML attribute.

type Attribute = { type: 'attribute', name: QName, value: text };

Element

Represents an XML element.

type Element = {
    type: 'element',
    name: QName,
    attributes: Attribute*,
    value: text?
};

Document

Represents an XML document with a root element.

type Document = { root: Element };

Node

A union type representing different kinds of XML nodes.

type Node = Element | Attribute | text;

Functions

Functions for reading XML

parse(value: text) -> Document

Parses an XML string into a Document.

  • value: The XML text to parse.

  • Returns: A Document representing the parsed XML.

getDescendants(self el: Element) -> Element*

Returns all descendant elements of the given element, including itself.

  • el: The element from which to start traversal.

  • Returns: A sequence of all descendant elements.

getNamedChildren(self el: Element?, localName: text) -> Element*

Finds all direct child elements with the given local name.

  • el: The parent element.

  • localName: The name of the child elements to retrieve.

  • Returns: A sequence of matching elements.

getNamedChild(self el: Element?, localName: text) -> Element?

Finds the first direct child element with the given local name.

  • el: The parent element.

  • localName: The name of the child element to retrieve.

  • Returns: The first matching child element or null if none is found.

getNamedAttribute(self el: Element?, localName: text) -> Attribute?

Finds an attribute by its local name.

  • el: The element to search in.

  • localName: The name of the attribute.

  • Returns: The matching attribute or null if not found.

getChildren(self el: Element?) -> Element*

Returns the direct children of an element.

  • el: The parent element.

  • Returns: A sequence of child elements.

Functions for creating XML

print(doc: Document) -> text

Serializes a Document into an XML string.

  • doc: The document to serialize.

  • Returns: The XML text representation of the document.

document(root: Element) -> Document

Creates a new XML document with the given root element.

  • root: The root element.

  • Returns: A Document.

element(name: text | QName, ...contents: Node*) -> Element

Creates an XML element with the given name and contents.

  • name: The name of the element.

  • contents: A sequence of child elements, attributes, and text nodes.

  • Returns: An Element.

attribute(name: text | QName, value: text) -> Attribute

Creates an XML attribute with the given name and value.

  • name: The name of the attribute.

  • value: The value of the attribute.

  • Returns: An Attribute.

qualifiedName(namespace: text?, localName: text) -> QName

Creates a qualified name with an optional namespace.

  • namespace: (Optional) The namespace.

  • localName: The local name.

  • Returns: A QName.

PreviousRecord moduleNextFilesystem Module

Last updated 4 months ago

Was this helpful?

⏸️