What is an XML Action?
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
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
- Click and drag the
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
icon from the toolbar onto the canvas - Enter a name for the XML action, then select Create Action
- In the XML action
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
on the right, populate the following details:
Field | Description | Example Value |
---|
Name | Name 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 |
---|
nopanel | true |
---|
|
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. |
Output Attributes
Contains a list of attributes returned by the node. In this node XML is converted into data objects that can be used by PhixFlow, this information is accessed using the syntax _result.
AttributeName
in an output attribute. To add an output attribute click the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
|
button and complete the appropriate details. For example:
XML Namespaces
The grid contains a list of the namespaces defined in an XML response.
To add a namespace to the list, click Image Removed Create New. PhixFlow opens a new XML Namespace property pane.
To remove a namespace, use the Image Removed Delete in the toolbar.
HTML Comment |
---|
Insert excerpt |
---|
XML Node | XML Node | name | WholePage |
---|
nopanel | true HTML Comment |
---|
Insert excerpt |
---|
| XML Node |
---|
| XML Node |
---|
name | WholePage |
---|
nopanel | true |
---|
|
|
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:
- A 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
- Create a new
Insert excerpt |
---|
| _tables |
---|
| _tables |
---|
nopanel | true |
---|
|
on your to save the BBC news data to, and ensure it contains the following attributes:- Name:
UID
- Type:
Integer
- Expression:
_NULL
- Name:
Title
- Type:
String
- Expression:
_NULL
- Name:
Description
- Type: Bigstring
- Expression:
_NULL
- Name:
Link
- Type:
String
- Expression:
_NULL
Actionflow Setup
- On the Shop News screen, add an Actionflow on the Start RSS Feed button
- Select Click to Connect and choose On Click
- Drag a action onto the canvas and give it a suitable name - this will be used to retrieve the news from the BBC XML
- Drag the connection point node onto the action
- Click on the action to open its Properties
- HTTP Method: GET
- URL: https://feeds.bbci.co.uk/news/technology/rss.xml
- Log Traffic:
Insert excerpt |
---|
| _toggle_off |
---|
| _toggle_off |
---|
nopanel | true |
---|
|
- Drag a
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
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 - Connect the out connector from the HTTP node to the XML node
- Click on the connector between the action and the
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
action- Map across all attributes
XML Action Setup
- Click on the
Insert excerpt |
---|
| _action_xml |
---|
| _action_xml |
---|
nopanel | true |
---|
|
action to open its Properties- Input Expression:
in.body
- Path:
/rss
Output Attributes:
Code Block |
---|
theme | Emacs |
---|
title | Name: Title, Type: String |
---|
|
_result.channel.title |
Code Block |
---|
theme | Emacs |
---|
title | Name: Description, Type: Bigstring |
---|
|
_result.channel.description |
Code Block |
---|
theme | Emacs |
---|
title | Name: Link, Type: String |
---|
|
_result.channel.link |
Code Block |
---|
theme | Emacs |
---|
title | Name: ID, Type: String |
---|
|
_NULL |
- Hover over the XML action and select out
- Create a
Insert excerpt |
---|
| _action_save |
---|
| _action_save |
---|
nopanel | true |
---|
|
action- Primary Table:
BBC_News
Save Action and Open Screen Action Setup
- Click on the connector between the XML action and the Save action
Map across the XML attributes to their relevant attributes on the Save action
Expand |
---|
|
Image Added |
Testing
- On the Shop News screen, lock the screen and click the Start RSS Feed button
- If the Actionflow is working, the BBC News grid should contain all of the BBC News data
1.02 Actionflow Principles