Partager via


Scanning for Relevant News (Windows CE 5.0)

Send Feedback

Some Web sites provide news headlines as part of their service. Some even filter the content according to user preferences. Using SAX2, you can create an application to scan the news and deliver only a subsection to a client browser.

For example, assume you have an XML news file, perhaps from a news feed, and you want to extract only a small portion of the news for a customer. Using a SAX application, you can search for specific stock symbols and extract news items only for the symbols that match the specified criteria.

In the following code, the parser reads the <stock> element, and then the <tkr> element and its contents. If the parser does not find a specified stock symbol, it continues the search and skips to the next stock symbol. If it finds a specified symbol, the parser returns the news item to the ContentHandler for processing.

Message 1
<stock> 
<tkr>FYI</tkr> 
<date>...</date> 
<news>...long text...</news> 
</stock> 
Message 2
<stock> 
<tkr>MSFT</tkr> 
<date>...</date> 
<news>...long text...</news> 
</stock>

For more information about implementing the ContentHandler, see JumpStart for Creating a SAX2 Application.

See Also

SAX2 Implementation Examples

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.