Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_Banners
_Banners
nameactionflow
nopaneltrue

What is an XML Action?

Insert excerpt
_action_xml
_action_xml
nopaneltrue
 actions process XML data, and convert it into specific data objects that can be used by PhixFlow for processing. The XML action extracts one or more records from the provided XML document using the XPath specified.

Creating XML Actions

  1. Click and drag the 
    Insert excerpt
    _action_xml
    _action_xml
    nopaneltrue
     icon from the toolbar onto the canvas
  2. Enter a name for the XML action, then select Create Action
  3. In the XML action 
    Insert excerpt
    _property_settings
    _property_settings
    nopaneltrue
     on the right, populate the following details:
FieldDescriptionExample Value
NameName given to the XML Node. This will be displayed on the Actionflow canvas.MyXMLReader
Input Expression

The input expression provides the source of the XML data to be operated upon. Typically, this will be a simple expression pointing at an incoming attribute, such as, the body from a HTTP Node.

// Consists of the pipe name and the name of a mapped attribute

in.body

XPath

The XPath expression is evaluated against the XML document provided by the Input Expression and returns a list of XML elements. It determines which elements are extracted from the XML.

Note that the XPath determines the number of elements that are processed, which directly correlates to the number of records returned by the XML Node. For example, if the path returns the route element of the XML Document, only one record will be returned. Whereas a path that returns children nodes will return one record for each child element.

// XML XPath

/root/main/title

4. 

Insert excerpt
_finish
_finish
nopaneltrue
 all settings

XPath Syntax

Expression Description

$ 

symbol refers to the root element.
@symbol refers to the current element.
. is the dot-child operator, which is used to denote a child element of the current element.
[ ] is used to select a child element of the current element (by name or index number).
*a wildcard, returning all elements regardless of their name.
^symbol is used to traverse up 1 element in the hierarchy from child to parent. 

What about / ?

Output Attributes

Contains Add a list of attributes to be returned by the node. In this node XML is converted into data objects that can be used by PhixFlow, this information is accessed XML action, using the syntax _result.AttributeName in an output attribute. To add an output attribute Output Attribute, click the 

Insert excerpt
_addIcon
_addIcon
nopaneltrue
 button and complete the appropriate details. For example:

XML Namespaces

XML Namespaces provide a method to avoid element name conflicts by ensuring they are unique. 

The grid contains a list of the namespaces defined in an XML responseXML documents containing namespaces are supported.

For more information on XML Namespaces, see https://www.w3schools.com/xml/xml_namespaces.asp and XML Namespace.

Example XML

Code Block
languagexml
<root xmlns:h="http://example.com/schema"> 
	<main page="PF Main Page"> 
		<h:title name="PF Title">PF Title Text">
			<h:datarow> 
				<h:data h:initials="AA">Alistair Andrews<data>
				<h:data h:initials="BB">Bert Brown</data> 
			</h:datarow> 
		</h:title> 
	</main> 
</root>

/root/main/title 

The following examples show how to reference the returned xPath's xml data structure in an Output Attribute:

  • Xpath value: _result → returns 'PF Title Text'
  • Xpath element attributes: _result.name → returns 'PF Title'
  • Xpath parent attributes: _result.^.page -> returns 'PF Main Page'
  • Xpath child attributes: listToString(_result.datarow.data.initials) → returns 'AA,BB'
  • Xpath child attribute text values: listToString(_result.datarow.data) → returns 'Alistair Andrews,Bert Brown'

Note the use of:

  • ^ to traverse to the immediate parent element.
  • . to traverse to the immediate child element.
  • the listToString function to handle multiple matching child elements/attributes.

Namespaces

Within path expressions, they are referred to using semicolons. 

  • /root/main/h:title

Within attribute expressions, a $ is used instead of the normal : namespace notation.

  • Xpath element attibutes: _result.h$name → returns 'PF Title'
  • Xpath child attributes: listToString(_result.h$datarow.h$data.h$initials) → returns 'AA,BB'
  • Xpath child attribute text values: listToString(_result.h$datarow.h$data.value) -> returns 'Alistair Andrews,Bert Brown'


The namespace prefix used here 'h' must be configured in the XML Namespace.

HTML Comment

Insert excerpt
XML Node
XML Node
nameWholePage
nopaneltrue

Worked Example

Here is a worked example using an XML file from BBC News (https://feeds.bbci.co.uk/news/technology/rss.xml).

In this example, we are using:  

  • Shop News screen containing a blank grid and a button  - this screen was created using the Multi-tile template
Tip

If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For these example, we'll be working on the Shop News screen

GIF/SCREENSHOT OF FINISHED RESULT   

Create a RRS Feed using XML Data

In this example, we'll create a table containing BBC News from an XML file.

Table Setup

  1. Create a new 
    Insert excerpt
    _tables
    _tables
    nopaneltrue
     on your 
    Insert excerpt
    _erd
    _erd
    nopaneltrue
     to save the BBC news data to, and ensure it contains the following attributes:
    1. Name: UID
      1. Type: Integer
      2. Expression: _NULL
    2. Name: Title
      1. Type: String
      2. Expression: _NULL
    3. Name: Description
      1. Type: Bigstring
      2. Expression: _NULL
    4. Name: Link
      1. Type: String
      2. Expression: _NULL

Actionflow Setup

  1. On the Shop News screen, add an Actionflow on the Start RSS Feed button
  2. Select Click to Connect and choose On Click
  3. Drag a 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action onto the canvas and give it a suitable name - this will be used to retrieve the news from the BBC XML
  4. Drag the 
    Insert excerpt
    _input
    _input
    nopaneltrue
     connection point node onto the
    Insert excerpt
    _http
    _http
    nopaneltrue
     action
  5. Click on the 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action to open its Properties
    1. HTTP Method: GET
    2. URL: https://feeds.bbci.co.uk/news/technology/rss.xml
    3. Log Traffic: 
      Insert excerpt
      _toggle_off
      _toggle_off
      nopaneltrue
  6. Drag a 
    Insert excerpt
    _action_xml
    _action_xml
    nopaneltrue
     action onto the canvas and give it a suitable name - this will be used to convert the XML data into data suitable for our BBC News table
  7. Connect the out connector from the HTTP node to the XML node
  8. Click on the connector between the 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action and the
    Insert excerpt
    _action_xml
    _action_xml
    nopaneltrue
     action
    1. Map across all attributes

XML Action Setup

  1. Click on the 
    Insert excerpt
    _action_xml
    _action_xml
    nopaneltrue
     action to open its Properties
    1. Input Expression: in.body
    2. Path: /rss
    3. Output Attributes:

      Code Block
      themeEmacs
      titleName: Title, Type: String
      _result.channel.title


      Code Block
      themeEmacs
      titleName: Description, Type: Bigstring
      _result.channel.description


      Code Block
      themeEmacs
      titleName: Link, Type: String
      _result.channel.link


      Code Block
      themeEmacs
      titleName: ID, Type: String
      _NULL


  2. Hover over the XML action and select out
  3. Create a
    Insert excerpt
    _action_save
    _action_save
    nopaneltrue
     action
    1. Primary Table: BBC_News

Save Action and Open Screen Action Setup

  1. Click on the connector between the XML action and the Save action
  2. Map across the XML attributes to their relevant attributes on the Save action

    Expand
    titleHow?


Testing

  1. On the Shop News screen, lock the screen and click the Start RSS Feed button
  2. If the Actionflow is working, the BBC News grid should contain all of the BBC News data


1.02 Actionflow Principles