Scanning for Part Availability
A version of this page is also available for
4/8/2010
With SAX2, you can retrieve a small subset of information from a large file and then abort processing. For example, assume you want to build an application to check on inventory levels for a specific part. The data source file containing parts information is rather large, and each part contains a sizeable number of fields.
Using SAX2, you can create an application that reads the data source, finds the specific part number, returns the quantity of available parts, and then aborts processing. In such a case, SAX2 offers two advantages. First, the parser only reads the file up to the point where the search information is found. Second, with SAX2, the application gets only the required fields in a record and skips the remaining fields, as shown in bold in the following code sample.
part>
<no>0Z5412H3</no>
<name>XYZ Valve</name>
<price>$35</price>
<stock>100</stock>
<source>...</source>
<ordered>3/2/2000</ordered>
<compatible>0Z5312H3</compatible>
<compatible>0Z1312P3</compatible>
<compatible>0Z3312E3</compatible>
</part>