Example 5 |
Top Previous Next |
Example 4
This filter script is designed to work with the National Weather service's XML content, which is generated by polling their web API.
Note: The <InputFile> and <OutputFile> sections are not icluded, so the script will use the filename passed in by PageGate, and write the script's results back to the same filename when done.
Note: Lines prefaced with # are comment lines for description purposes. The filter ignore any lines that begin with #
# This section of the filter grabs the data from the <weather> XML tag. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <weather>*</weather> </Text> </Search> <Replace> <Section> All </Section> <Scope> Section </Scope> <Text> Weather: %Match% </Text> </Replace> </Filter>
# This section of the filter grabs the data from the <temp_f> XML tag. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <temp_f>*</temp_f> </Text> </Search> <Replace> <Section> Temp </Section> <Scope> Section </Scope> <Type> Literal </Type> <Text> %Temp% \013\010Temperature: %Match% </Text> </Replace> </Filter>
# This section of the filter grabs the data from the <windchill_f> XML tag. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <windchill_f>*</windchill_f> </Text> </Search> <Replace> <Section> Temp </Section> <Scope> Section </Scope> <Type> Literal </Type> <Text> %Temp% \013\010Windchill: %Match% </Text> </Replace> </Filter>
# This section removes the literal text <weather> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <weather> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section removes the literal text </weather> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> </weather> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section removes the literal text <temp_f> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <temp_f> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section removes the literal text </temp_f> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> </temp_f> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section removes the literal text <windchill_f> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> <windchill_f> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section removes the literal text </windchill_f> from the text to be processed. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> </windchill_f> </Text> </Search> <Replace> <Section> All </Section> <Scope> Match </Scope> <Text>
</Text> </Replace> </Filter>
# This section provides the recipient and sender information necessary # to process this data in to an SMS. Effectively, what you're doing is # telling the program who this weather data should go to by outputting # information in the GetASCII API's basic format. The \013\010 # statements represent a carriage return followed by a line feed and are # required. With the example provided below, this will process all # traffic to a single recipient or group named customer-phone. <Filter> <Search> <Section> All </Section> <Type> Literal </Type> <Text> * </Text> </Search> <Replace> <Section> All </Section> <Scope> Section </Scope> <Text> customer-phone\013\010Weather\013\010%Match% </Text> </Replace> </Filter>
|