Microsoft SDK for Java

Document Class

The Document class of the com.ms.xml.om package implements an XML document, which can be thought of as the root of a tree.

public class Document extends ElementImpl implements ElementFactory
{
  // Fields
  protected DTD dtd;
  protected ElementFactory factory;

  // Constructors
  public Document();
  public Document(ElementFactory f);

  // Methods
  public void addChild(Element elem, Element after);
  public void clear();
  public final Element createElement(Element parent,
    int type, Name tag, String text);
  public final Element createElement(int type, String tag);
  public final Element createElement(int type);
  public XMLOutputStream createOutputStream(OutputStream out)
    throws IOException;
  public final Enumeration elementDeclarations();
  public Element findEntity(Name name);
  public final String getCharset();
  public final String getDocType();
  public DTD getDTD();
  public final String getDTDURL();
  public Element getElementDecl(Name name);
  public final String getEncoding();
  public long getFileModifiedDate();
  public final String getId();
  public int getOutputStyle();
  public Element getParent();
  public final Element getRoot();
  public final String getStandalone();
  public String getText();
  public int getType();
  public final String getURL();
  public final String getVersion();
  public boolean isCaseInsensitive();
  public void load(String urlstr) throws ParseException;
  public void load(URL url) throws ParseException;
  public void load(InputStream in) throws ParseException;
  public boolean loadExternal();
  public void parsed(Element e);
  public void parsedAttribute(Element e, Name name, Object value);
  public void removeChild(Element elem);
  public void reportError(ParseException e, OutputStream out);
  public void save(XMLOutputStream o) throws IOException;
  public void setCaseInsensitive(boolean yes);
  public final void setCharset(String encoding);
  public final void setEncoding(String encoding);
  public void setLoadExternal(boolean yes);
  public void setOutputStyle(int style);
  public void setShortEndTags(boolean yes);
  public final void setStandalone( String value );
  public void setText(String text);
  public void setURL(String urlstr) throws ParseException;
  public final void setVersion(String version);
  public void setShortEndTags(boolean yes);
  public boolean shortEndTags();
}

Each XML tag can either represent a node or a leaf of this tree. The Document class allows you to load an XML document, manipulate it, and then save it back out again. The document can be loaded by specifying a URL or an input stream.

According to the XML specification, the root of the tree consists of any combination of comments and processing instructions, but only one root element. A helper method, getRoot, is provided as a shortcut to finding the root element.

See Also

com.ms.xml.om.Element

Hierarchy

ElementImpl 
  |
  +--Document (Element)

© 1999 Microsoft Corporation. All rights reserved. Terms of use.