Package org.dom4j.io

Examples of org.dom4j.io.XMLWriter


    {
        StringWriter stringWriter = new StringWriter();

        try
        {
            XMLWriter xmlWriter = new XMLWriter(stringWriter);

            for (final Iterator iterator = element.nodeIterator(); iterator.hasNext();)
            {
                Node childElement = (Node)iterator.next();
                xmlWriter.write(childElement.getText());
            }

            xmlWriter.flush();
            xmlWriter.close();
        }
        catch (IOException ioe)
        {
            throw new JellyTagException("Unable parse source for syntax highlighting: ");
        }
View Full Code Here


    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, format);
      writer.write(this);
      writer.flush();

      return out.toString();
    } catch (IOException e) {
      throw new RuntimeException("IOException while generating textual "
          + "representation: " + e.getMessage());
View Full Code Here

  @Override
  public void write(Writer out) throws IOException {
    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    XMLWriter writer = new XMLWriter(out, format);
    writer.write(this);
  }
View Full Code Here

  }

  public String asXML() {
    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, new OutputFormat());

      writer.write(this);
      writer.flush();

      return out.toString();
    } catch (IOException e) {
      throw new RuntimeException("IOException while generating " + "textual representation: " + e.getMessage());
    }
View Full Code Here

    }
  }

  @Override
  public void write(Writer out) throws IOException {
    XMLWriter writer = new XMLWriter(out, new OutputFormat());
    writer.write(this);
  }
View Full Code Here

                        if (parent != null)
                        {
                            parent.mkdirs();
                        }
                       
                        XMLWriter writer = new XMLWriter(new FileWriter(fileOutput));
                        writer.write(document);
                        writer.flush();
                        writer.close();
                    }
                }
            }
        }
        catch (final Exception exception)
View Full Code Here

    OutputFormat format = OutputFormat.createPrettyPrint();
    if (encoding == null || "".equals(encoding.trim())) {
      encoding = "GBK";
    }
    format.setEncoding(encoding);
    XMLWriter xmlwriter = new XMLWriter(writer, format);

    try {
      xmlwriter.write(doc);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return writer.toString();
View Full Code Here

                }
            }
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(selectedFile));
            OutputFormat format = OutputFormat.createPrettyPrint();
            format.setEncoding("UTF-8");
            XMLWriter xmlWriter = new XMLWriter(bos, format);
            xmlWriter.write(document);
            xmlWriter.flush();
            xmlWriter.close();
            LOG.info(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "File xml saved."));
        } else {
            LOG.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                    "Error saving xml file, output file is null."));
        }
View Full Code Here

         }

         File versionsXml = new File(jbossHome, "jar-versions.xml");
         FileWriter versionInfo = new FileWriter(versionsXml);
         OutputFormat outformat = OutputFormat.createPrettyPrint();
         XMLWriter writer = new XMLWriter(versionInfo, outformat);
         writer.setEscapeText(true);
         writer.write(doc);
         writer.flush();
         versionInfo.close();
      }
      catch(IOException e)
      {
         e.printStackTrace();
View Full Code Here

  }

  private XMLWriter getWriter() throws IOException {
    if (xmlWriter == null) {
      if (this.outputFormat != null) {
        xmlWriter = new XMLWriter(outputFormat);
      } else {
        xmlWriter = new XMLWriter();
      }
    }

    return xmlWriter;
  }
View Full Code Here

TOP

Related Classes of org.dom4j.io.XMLWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.