Java Utililty Methods XML Node Save

List of utility methods to do XML Node Save

Description

The list of methods to do XML Node Save are organized into topic(s).

Method

voidsave(String filename, Node node)
save
PrintStream out = null;
try {
    out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
    print(out, node);
} catch (Exception ex) {
    throw new IOException(ex.getLocalizedMessage());
} finally {
    if (out != null)
...
ResultSettoResultSet(Node node, ResultSet rs)
to Result Set
int type = node.getNodeType();
if (type == Node.ELEMENT_NODE) {
    NamedNodeMap nnm = node.getAttributes();
    String name = node.getNodeName();
    String value = "";
    Node next = node.getFirstChild();
    if (next != null) {
        type = next.getNodeType();
...
voidwrite(Node node, Writer out)
write
write(node, out, false);
voidwriteByDom(Node node, Writer writer, int indent)
write By Dom
try {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS domImpLS = (DOMImplementationLS) registry.getDOMImplementation("LS 3.0");
    LSOutput output = domImpLS.createLSOutput();
    output.setCharacterStream(writer);
    output.setEncoding("utf-8");
    LSSerializer serializer = domImpLS.createLSSerializer();
    serializer.setNewLine("\n");
...
voidwriteDescription(PrintWriter out, Node node, String offSet)
Parses and writes the description of a given Node into the output stream
Node childNodeDescriptive = null;
Node childNodeBrief = null;
Node childNodeDescription = null;
if (node == null)
    return;
childNodeDescriptive = getNodeByName("descriptive", node.getChildNodes());
if (childNodeDescriptive == null)
    return;
...
voidwriteDOM(Node node, PrintWriter writer)
Recursively write the XML DOM representation into a print writer output stream.
if (node != null) {
    switch (node.getNodeType()) {
    case Node.DOCUMENT_NODE:
        writer.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + EOL);
        DocumentType doctype = ((Document) node).getDoctype();
        if (doctype != null) {
            writer.print("<!DOCTYPE ");
            writer.print(doctype.getName());
...
voidwriteNode(Node n, FileOutputStream o)
Writes a DOM node (and all its ancestors) to the given output stream
PrintWriter w = new PrintWriter(o);
w.print(n.toString());
w.close();
voidwriteNode(Node n, Writer w)
Writes a node using the given writer.
switch (n.getNodeType()) {
case Node.ELEMENT_NODE:
    w.write("<");
    w.write(n.getNodeName());
    if (n.hasAttributes()) {
        NamedNodeMap attr = n.getAttributes();
        int len = attr.getLength();
        for (int i = 0; i < len; i++) {
...
voidwriteNode(Node node, OutputStream os, boolean formatted)
write Node
DOMImplementationRegistry domImplementationRegistry = DOMImplementationRegistry.newInstance();
DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementationRegistry
        .getDOMImplementation("LS");
LSOutput lsOutput = domImplementationLS.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(os);
LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
if (formatted)
...
voidwriteNode(Node node, OutputStream output, Map serializerParams)
Writes a Node out to an OutputStream using the DOM, level 3, Load/Save serializer.
DOMImplementationLS domImplLS = getLSDOMImpl(node);
LSSerializer serializer = getLSSerializer(domImplLS, serializerParams);
LSOutput serializerOut = domImplLS.createLSOutput();
serializerOut.setByteStream(output);
serializer.write(node, serializerOut);