| <?xml version="1.0" standalone="no"?> |
| <!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd"> |
| |
| <s1 title="&XercesCName; Sample 4"> |
| |
| <s2 title="DOMPrint"> |
| <p>DOMPrint parses an XML file, constructs the DOM tree, and walks |
| through the tree printing each element. It thus dumps the XML back |
| (output same as SAXPrint).</p> |
| |
| <s3 title="Building on Windows"> |
| <p>Load the &XercesCInstallDir;-win32\samples\Projects\Win32\VC6\samples.dsw |
| Microsoft Visual C++ workspace inside your MSVC IDE. Then |
| build the project marked DOMPrint. |
| </p> |
| </s3> |
| <s3 title="Building on UNIX"> |
| <source>cd &XercesCInstallDir;-linux/samples |
| ./runConfigure -p<platform> -c<C_compiler> -x<C++_compiler> |
| cd DOMPrint |
| gmake</source> |
| <p> |
| This will create the object files in the current directory and the executable named |
| DOMPrint in '&XercesCInstallDir;-linux/bin' directory.</p> |
| |
| <p>To delete all the generated object files and executables, type</p> |
| <source>gmake clean</source> |
| </s3> |
| |
| <s3 title="Running DOMPrint"> |
| |
| <p>The DOMPrint sample parses an XML file, using either a validating |
| or non-validating DOM parser configuration, builds a DOM tree, |
| and then walks the tree and outputs the contents of the nodes |
| in a 'canonical' format. To run DOMPrint, enter the following:</p> |
| <source>DOMPrint [-v] <XML file></source> |
| <p>The -v option is used when you wish to use a validating parser. Here is a |
| sample output for DOMPrint when the validating parser is used: </p> |
| <source>cd &XercesCInstallDir;-linux/samples/data |
| DOMPrint -v personal.xml</source> |
| <p>Here is a sample output from DOMPrint</p> |
| <source>cd &XercesCInstallDir;-linux/samples/data |
| DOMPrint -v personal.xml |
| |
| <?xml version='1.0' encoding='utf-8?> |
| <!-- Revision: 63 1.7 samples/data/personal.xml --> |
| <personnel> |
| |
| <person id="Big.Boss"> |
| <name><family>Boss</family> <given>Big</given></name> |
| <email>chief@foo.com</email> |
| <link subordinates="one.worker two.worker three.worker |
| four.worker five.worker"></link> |
| </person> |
| |
| <person id="one.worker"> |
| <name><family>Worker</family> <given>One</given></name> |
| <email>one@foo.com</email> |
| <link manager="Big.Boss"></link> |
| </person> |
| |
| <person id="two.worker"> |
| <name><family>Worker</family> <given>Two</given></name> |
| <email>two@foo.com</email> |
| <link manager="Big.Boss"></link> |
| </person> |
| |
| <person id="three.worker"> |
| <name><family>Worker</family> <given>Three</given></name> |
| <email>three@foo.com</email> |
| <link manager="Big.Boss"></link> |
| </person> |
| |
| <person id="four.worker"> |
| <name><family>Worker</family> <given>Four</given></name> |
| <email>four@foo.com</email> |
| <link manager="Big.Boss"></link> |
| </person> |
| |
| <person id="five.worker"> |
| <name><family>Worker</family> <given>Five</given></name> |
| <email>five@foo.com</email> |
| <link manager="Big.Boss"></link> |
| </person> |
| |
| </personnel></source> |
| <p>Note that DOMPrint does not reproduce the original XML file. Also DOMPrint and |
| SAXPrint produce different results because of the way the two APIs store data |
| and capture events.</p> |
| </s3> |
| </s2> |
| </s1> |