Member Junction
    Preparing search index...

    Action that parses XML data and extracts content using XPath expressions Supports namespaces, various return types, and multiple input sources

    // Parse XML and extract with XPath
    await runAction({
    ActionName: 'XML Parser',
    Params: [{
    Name: 'XMLData',
    Value: '<users><user id="1"><name>John</name></user><user id="2"><name>Jane</name></user></users>'
    }, {
    Name: 'XPathExpression',
    Value: '//user[@id="1"]/name/text()'
    }]
    });

    // Parse XML with namespaces
    await runAction({
    ActionName: 'XML Parser',
    Params: [{
    Name: 'XMLData',
    Value: '<ns:root xmlns:ns="http://example.com"><ns:value>Test</ns:value></ns:root>'
    }, {
    Name: 'XPathExpression',
    Value: '//ns:value/text()'
    }, {
    Name: 'NamespaceMap',
    Value: { ns: 'http://example.com' }
    }]
    });

    // Convert entire XML to JSON
    await runAction({
    ActionName: 'XML Parser',
    Params: [{
    Name: 'XMLData',
    Value: '<root><item>Value 1</item><item>Value 2</item></root>'
    }]
    });

    Hierarchy

    • BaseFileHandlerAction
      • XMLParserAction
    Index

    Constructors

    Methods

    • Get file content from various sources based on parameters Priority: FileID > FileURL > Data parameter

      Parameters

      • params: RunActionParams

        Action parameters

      • dataParamName: string

        Name of the parameter containing direct data

      • fileParamName: string = 'FileID'

        Name of the parameter containing file ID (default: 'FileID')

      • urlParamName: string = 'FileURL'

        Name of the parameter containing file URL (default: 'FileURL')

      Returns Promise<
          {
              content: string
              | Buffer;
              fileName?: string;
              mimeType?: string;
              source: "url" | "storage" | "direct";
          },
      >

      Object with content and metadata

    • Parses XML and extracts data using XPath expressions

      Parameters

      • params: RunActionParams

        The action parameters containing:

        • XMLData: String containing XML data (direct input)
        • FileID: UUID of MJ Storage file (alternative)
        • FileURL: URL of XML file (alternative)
        • XPathExpression: XPath query to extract data (optional - if not provided, converts entire XML to JSON)
        • NamespaceMap: Object mapping namespace prefixes to URIs
        • ReturnType: "string" | "number" | "boolean" | "node" | "nodes" | "json" (default: "string")
        • PreserveAttributes: Boolean - include attributes in JSON conversion (default: true)
        • ExplicitArray: Boolean - always put child nodes in array (default: false)
        • IgnoreAttributes: Boolean - ignore attributes in conversion (default: false)

      Returns Promise<ActionResultSimple>

      Extracted data based on XPath or full JSON conversion

    • Executes the action with the provided parameters.

      Parameters

      Returns Promise<ActionResultSimple>

      Promise resolving to the action result

    • Save file to MJ Storage. Uploads the content to a FileStorageAccount and creates the corresponding MJ: Files entity record.

      Parameters

      • content: string | Buffer

        File content as string or Buffer

      • fileName: string

        Name for the file

      • mimeType: string

        MIME type of the file

      • params: RunActionParams

        Action parameters (for contextUser)

      • OptionalstorageAccountName: string

        Optional: name of the storage account to use (falls back to first active)

      • OptionalstoragePath: string

        Optional: custom storage path prefix (falls back to artifacts/{date}/{uuid}/)

      Returns Promise<string>

      The ID of the newly created MJ: Files record