|
|
|||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||
Part 2 Java XML Programmers Reference Chapter 11: XML Tools for Information Appliances September 24, 2001
net.n3.nanoxml
public class StdXMLReader The StdXMLReader class implements IXMLReader, an interface called by StdXMLParser to read XML data from a data source. It is the default implementation of IXMLReader used by XMLParserFactory. Since you probably won't be implementing your own reader or parser, we'll only discuss two methods in this class. They allow you to choose one of two different data sources: java.io.Reader or java.lang.String. public StdXMLReader(Reader reader) public static IXMLReader stringReader(String str) The first method, the constructor, is the one to use to read from a Reader. The second, static method, stringReader(), is the method to use to read from a String.
Class StdXMLParser public class StdXMLParser extends java.lang.Object implements net.n3.nanoxml.IXMLParser The StdXMLParser class implements the IXMLParser interface. This interface is provided so that you can write your own parser and plug it into your application, if needed. StdXMLParser is a default implementation and is used by XMLParserFactory. Unless you plan on implementing your own parser that meets the IXMLParser contract, you should use instances of StdXMLParser. Here are its methods:
You really will not need to call any of these methods unless you:
Arguments
Here is an example that parses a document using the XMLParserFactory and StdXMLParser classes.
Class XMLWriter net.n3.nanoxml
public class XMLWriter The XMLWriter class is used to output an XML document. In version 1.6.7, this functionality was included in the XMLElement class as write() methods. In version 2.0, however, a new class has been created to handle output, making the library more object-oriented. public XMLWriter(Writer writer) public XMLWriter(OutputStream st) public void write(XMLElement elem) public void write(XMLElement elem, int indent) The entire document, or a document fragment, can be written to any class extending java.io.Writer or java.io.OutputStream. There are no output options; all attributes and #PCDATA are always output for each element. Arguments
We'll use the example we've been building upon to write a full application that parses an XML document called request.xml and echoes its contents to System.out:
Coming Up Next: MinML | |||||||||||||||||||||||||||||
|
PAGE: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | FIRST PAGE |
|||||||||||||||||||||||||||||













