Polycom Digital Signage Administrator Guide

Data Source Tutorial

 

 

</ParsingRule>

</DataItem>

This changes the way Data Parse handles the second rule. Because it is a now child rule, the current DataItem iteration is not passed to it as an Index value. This makes the rule use the default index value (1), and so it now always retrieves the text between the first occurrence of <b> and </b>.

A different way we could have solved this problem would be to instead add an Index parameter to the second GetTag rule so that it always extracts from the first occurrence:

<DataItem NumRecords="9" ClearTableOnStart="True"> <ParsingRule type="GetTag" Source="Source" result="DaySource"> <StartTag><td </StartTag> <EndTag></td></EndTag>

</ParsingRule>

<ParsingRule type="GetTag" source="DaySource" result="DayPart"> <StartTag><b></StartTag> <EndTag></b></EndTag>

<Index>1</Index>

</ParsingRule>

</DataItem>

However, using child rules is preferred because it's easy to forget to include that Index parameter.

Let's return to the tutorial. Now that we have the day part name, but if you look carefully at what's between the <b> and </b> tags you'll see that the day part name always has a "<br>" string. Sometimes it's just at the end of the string, as in "Friday<br>", and other times it's in the middle, as in "Friday<br>Night". Let's replace that "<br>" with a space:

<ParsingRule type="Replace" source="DayPart" result="DayPart"> <SearchText><br></SearchText> <NewText><space></NewText>

</ParsingRule>

Note the use of "<space>" (with the < and > substituted by entity codes) as the NewText parameter. We have to use the <space> token because XML strips spaces from values. If we had simple used a space character, as in <NewText> </NewText>, we would actually be removing the SearchText instead of replacing it with a space. This would result in translating day part names like "Friday<br>Night" to "FridayNight" instead of "Friday Night".

With the day part name safely in the DayPart field of the table, let's extract the weather conditions. For this, we want part of the phrase that's used as the title attribute of the <img> element (such as title="Heavy Rain Chance for Measurable Precipitation 70%"). We only want the "Heavy Rain" part, so we want to drop the "Chance for …" text.

186

Polycom, Inc.

Page 196
Image 196
Polycom PDS 2000 manual ParsingRule DataItem