Drucegrove DragonFly User Manual 1.4
Page 46
The following is an example of a Parser XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Parser>
<Settings>
<Arg ID="id"
Name="Location ID"
Description="The BBC Weather location ID" />
</Settings>
<Variables>
<Variable Name="WEATHER_SOURCE" Value="BBC Weather" />
<DateTime Name="WEATHER_UPDATED" />
</Variables>
<Source
URL="http://open.live.bbc.co.uk/weather/feeds/en/{id}/observations.rss"
>
<Read Mode="xml"
Path="/rss/channel/item/title"
Instance="1"
Variable="WEATHER_TITLE" />
</Source>
</Parser>
The parser has a single
Argument
(shown in red). Arguments are optional, and are usually used in the source URL for
the feed. If the feed only has a single source URL with no variables then the arguments do not need to be included.
In this example, the BBC feed URL has an ID number for the location which has been defined here as an argument
called “id”. When this parser is selected in the DragonFly Designer or Remote Configuration software then the user
will be required to enter the “Location ID” for the feed.
The parser can be configured to output variables that do not relate to a downloaded feed, such as static text or the
current date and time. This parser will output a single static
Variable
(shown in purple) called “WEATHER_SOURCE”
which will always be given the value “BBC Weather”. This parser will also output a
DateTime
variable called
“WEATHER_UPDATED” (shown in orange. The value of this DateTime variable will be set to the current date and
time.
The parser has a single
Source URL
(shown in green). The URL includes the “id” attribute encapsulated in braces
(highlighted in yellow). When the URL is downloaded, {id} will be replaced by the valued of the “id” argument.
Once the data is downloaded from the URL,
Read Actions
are performed. There is one read action in this example
(shown in blue). The read mode of this action is “xml”, which means the data will be parsed as XML from the path
specified by the “Path” attribute.
There is only a single instance of the <title> element, so the “Instance” attribute is set to “1”. Had there have been
multiple <title> elements then the instance attribute would instruct the parser on which element to select.
Finally, the Variable specified in this read action instructs the parser to place the value of the read into a variable
called “WEATHER_TITLE”. This would then mean that DragonFly layout elements can use or display the value of the
weather title by referencing the “WEATHER_TITLE” variable.
Note: It is possible to nest read actions. A read action will be performed on its parent’s resultant data.