SAXWriter and DOMWriter parse your input file, and print it out in XML format. A command line option can be used to print in a "canonical" XML format, so the output can be used to compare XML documents. SAXWriter and DOMWriter also display any errors or warnings that occurred during the parse. SAXWriter uses either the validating or non-validating SAX parser. DOMWriter uses either the validating or non-validating DOM parser. DOMWriter provides a -e switch to set the output Java encoding. The command lines below expect the current directory to be the directory containing the JAR file. Requirements:
Source code:
To run SAXWriter:
On Windows: The easiest way to do this is to create a .bat file using the Notepad editor. Then the SAXWriter can be invoked by double clicking on the file name or icon. The following command lines assume that both the jdk and the xml4j directories are located directly below the c: dirve. set path=c:\jdk1.1.8\bin;%PATH% Switches: SAXWriter also allows you to change the default behavior with the following command line flags:
com.ibm.xml.parsers.SAXParser [default parser] com.ibm.xml.parsers.ValidatingSAXParser Running SAXWriter with the default settings is equivalent to running SAXWriter like this (type this as one long command line): java sax.SAXWriter -p com.ibm.xml.parsers.SAXParser Bringing up the help information: java sax.SAXWriter -h Print in canonical format: java sax.SAXWriter -c data\personal.xml Note: Parse your own XML file instead of data\personal.xml
To run DOMWriter:
On Windows: The easiest way to do this is to create a .bat file using the Notepad editor. Then the DOMWriter can be invoked by double clicking on the file name or icon. The following command lines assume that both the jdk and the xml4j directories are located directly below the c: dirve. set path=c:\jdk1.1.8\bin;%PATH% Switches: DOMWriter also allows you to change the default behavior via the following command line flags:
dom.wrappers.NonValidatingDOMParser dom.wrappers.DOMParser [default parser] dom.wrappers.TXParser Running DOMWriter with the default settings is equivalent to running DOMWriter like this (type this in as one long command line): java dom.DOMWriter -p dom.wrappers.DOMParser Bringing up the help information: java dom.DOMWriter -h Searching for elements: java dom.DOMWriter -c data\personal.xml Running DOMWriter with the -e switch and no encoding specified will print out a list of valid encoding names: java dom.DOMWriter -e Prints the following: Java Encoding one of( case sensitive ): Note: Parse your own XML file instead of data\personal.xml |