Rather than build a DOM structure with low-level elements, attributes, and processing instructions, you can build the document structure more efficiently and quickly using SAX. In some cases, you might want to use SAX to create a data structure using only high-level objects, such as stock symbols and news, and then combine the data from this XML file with other news sources. When you want to create a new document structure Scanning only a small percentage of the document results in a significant savings of system resources. With SAX, your application can scan the data for news related only to the stock symbols you indicate, and then create a slimmed-down document structure to pass along to a news service. For example, if you want to scan data for relevant news about a particular stock, it's inefficient to read the unnecessary data into memory. When you want to retrieve small amounts of informationįor many XML-based solutions, it is not necessary to read the entire document to achieve the desired results. When the application finds the part, it returns the part number and availability, and then stops processing. For example, you can create an application that searches for a part in inventory. When you need to abort parsingīecause SAX allows you to abort processing at any time, you can use it to create applications that fetch particular data. If you must process large documents, SAX is the better alternative, particularly if you do not need to change the contents of the document. For example, a 100 kilobyte (KB) document can occupy up to 1 megabyte (MB) of memory using the DOM the same document requires significantly less memory when using SAX. With SAX, memory consumption does not increase with the size of the file. Perhaps the biggest advantage of SAX is that it requires significantly less memory to process an XML document than the DOM. As an events-based parser that processes documents in a serial manner, the Simple API for XML (SAX) presents an excellent alternative to the Document Object Model (DOM).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |