Data Source Tutorial | Appendix B: Data Parser |
|
|
Now that we've isolated the weather data for a single day part, we can extract that data and save it in a row of our table. First we obtain the name of the day part using a GetTag rule to extract the text the lies between the <b> and </b> tags in the DaySource container:
<ParsingRule type="GetTag" source="DaySource" result="DayPart"> <StartTag><b></StartTag> <EndTag></b></EndTag>
</ParsingRule>
There's a subtle problem here. What we want is to extract the text from between the first (indeed, the only) pair of <b> and </b> tags. However, simply adding the above rule to the <DataItem> element will not work:
<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>
</ParsingRule>
</DataItem>
The above code will only extract the first day part's name, but will not extract anything for subsequent day parts. To understand why, recall that the GetTag rule is
To achieve what we want, the second rule has to be made a child of the first rule:
<DataItem NumRecords="9" ClearTableOnStart="True"> <ParsingRule type="GetTag" Source="Source" result="DaySource"> <StartTag><td </StartTag> <EndTag></td></EndTag>
<ParsingRule type="GetTag" source="DaySource" result="DayPart"> <StartTag><b></StartTag> <EndTag></b></EndTag>
</ParsingRule>
Polycom, Inc. | 185 |