Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is an XML Action?
Image Modified
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Creating XML Actions
- Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_xml _action_xml nopanel true - Enter a name for the XML action, then select Create Action
- In the XML action
on the right, populate the following details:Insert excerpt _property_settings _property_settings nopanel true
Field | Description | Example Value |
---|---|---|
Name | Name given to the XML Node. This will be displayed on the Actionflow canvas. | MyXMLReader |
Input Expression | This field is mandatory. 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
|
XPath | The XPath |
is used to navigate through elements and attributes in an XML document and determines which elements are extracted from the XML. |
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 |
XPath returns the |
root element of the XML |
document, only one record will be returned. Whereas |
if the XPath returns children |
elements, one record will be returned for each child element. | // XML XPath /root/main/title |
4.
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
XPath Syntax
Expression | Description |
---|
/ |
@
.
Traverses down into the XML structure. It is the child operator, |
used to denote a child element of the current element. All elements are delimited using this notation, e.g. /rss/Item/Date , will return the value held in the Date element. | |
.. | Traverses up 1 element in the hierarchy from child to parent. |
[ ] |
Selects a child element of the current element (by name or index number). | |
@ | Selects all attributes with the specified name e.g. //@foo will return all attributes named foo in the XML document. See Attributes vs Elements for details. |
// | Selects elements, from within the current element, that match the selection regardless of their location e.g. /root/item//bar will return all bar elements from within item. |
* | Is a wildcard, returning all elements regardless of their name. |
See XML and XPath and XPath Syntax for examples of how different XPath expressions provide different results.
Output Attributes
Add a list of attributes to be returned by the XML action, using the
value _result.
AttributeName
followed by the Attribute Expression Syntax (see below) and the name of the element/attribute required. To add an Output Attribute, click the
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Image Modified
Attribute Expression Syntax
Expression | Description |
---|---|
. | Traverses down into the XML structure. It is the child operator, used to denote a child element of the current element. All elements are delimited using this notation e.g. |
^ | Traverses up 1 element in the hierarchy from child to parent. |
[ ] | Selects a child element of the current element (by name or index number). |
* | Is a wildcard, returning all elements regardless of their name. |
@ | Selects all attributes with the specified name, e.g. //@foo will return all attributes named foo in the XML document. |
XML Namespaces
XML Namespaces provide a method to avoid element name conflicts by ensuring they are unique.
XML documents containing namespaces are supported.
For more information on XML Namespaces, see https://www.w3schools.com/xml/xml_namespaces.asp and XML Namespace. Also, see Namespaces in the Example XML below.
Example XML
Expand | |||||
---|---|---|---|---|---|
| |||||
XPath
ResultsThe following examples show how to reference the returned |
XPath's |
XML data structure in an Output Attribute: |
|
|
|
|
|
|
|
|
|
|
|
|
Note the use of:
|
|
|
NamespacesXPathWithin path expressions, |
namespaces are referred to using semicolons.
A record is created for each element returned by the path. Therefore, we do not recommend returning the root as this only returns a single record. ResultsWithin attribute expressions, a $ is used instead of the normal : namespace notation. |
|
|
|
|
|
|
|
|
The namespace prefix used here ' |
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 RRSExcerpt | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
Create an RSS Feed using XML DataIn this example, we'll create a table containing BBC News from an XML file. Image Added Table Setup
|
|
Actionflow Setup
|
|
|
|
|
|
|
XML Action Setup
|
|
|
|
BBC_News
Save Action and Open Screen Action Setup
Click on the connector between the XML action and the Save action
|
Screen Setup
Testing
|
|
|
On this page
Table of Contents | ||
---|---|---|
|