Compartilhar via


Create a DOMDocument Object from SAX Events

 

With MSXML, you can generate a DOMDocument (or FreeThreadedDOMDocument) object from SAX events. This feature is useful when you want to create a small subset of XML from a large XML document and then use the DOM to process the results. For example, you might want to parse only small portions of a catalog, such as a <book> node, and store the results in a DOM object. You can then use the DOM to compare content, walk the DOM tree, and modify or update content. In addition, you might want to use SAX to search a large catalog file for a particular book. For performance gains, you can use SAX to locate a single item and then abort parsing after it is located. You can output the results of the search into a DOMDocument object and then apply DOM methods to the object.

This topic provides a simple example that demonstrates how to set a DOM object as the destination output for SAX events. It also provides implementation notes that describe some of the restrictions on the SAX to DOM implementation.