http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Installation
Build

Downloads

API Docs
Samples
Programming
Migration
FAQs

Releases
Caveats
Feedback

SAXPrint
 

SAXPrint uses the SAX APIs to parse an XML file and print it back. Do note that the output of this sample is not exactly the same as the input (in terms of whitespaces, first line), but the output has the same information content as the input.

Building on Windows
 

Load the xerces-c-1_1_0-win32\samples\Projects\Win32\VC6\samples.dsw Microsoft Visual C++ workspace inside your MSVC IDE. Then build the project marked SAXPrint.


Building on UNIX
 
cd xerces-c-1_1_0-linux/samples
./runConfigure -p<platform> -c<C_compiler> -x<C++_compiler>
cd SAXPrint
gmake

This will create the object files in the current directory and the executable named SAXPrint in 'xerces-c-1_1_0-linux/bin' directory.

To delete all the generated object files and executables, type

gmake clean

Running SAXPrint
 

The SAXPrint sample parses an XML file and prints out the contents again in XML (some loss occurs). To run SAXPrint, enter the following

SAXPrint <XML file>

To use the validating parser, use

SAXPrint -v <XML file>

Here is a sample output from SAXPrint

cd xerces-c-1_1_0-linux/samples/data
SAXPrint -v 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>
NoteSAXPrint does not reproduce the original XML file. Also SAXPrint and DOMPrint produce different results because of the way the two APIs store data and capture events.



Copyright © 2000 The Apache Software Foundation. All Rights Reserved.