Package org.jdom2.output

Examples of org.jdom2.output.XMLOutputter


     @return HTML
     */
    public static String element2String( Element element )
    {
        Document document = new Document( element );
        XMLOutputter outputter = new XMLOutputter();
        return outputter.outputString( document );
    }
View Full Code Here


        throws IOException
    {
        m_document.setContext( m_context );

        CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
        XMLOutputter output = new XMLOutputter(processor);
       
        StringWriter out = new StringWriter();
       
        Format fmt = Format.getRawFormat();
        fmt.setExpandEmptyElements( false );
        fmt.setLineSeparator( LINEBREAK );

        output.setFormat( fmt );
        output.outputElementContent( m_document.getRootElement(), out );
       
        String result = out.toString();
        return result;
    }
View Full Code Here

        Element rootElement = m_document.getRootElement();
        processChildren( rootElement );

        m_document.setContext( m_context );

        XMLOutputter output = new XMLOutputter();

        StringWriter out = new StringWriter();

        Format fmt = Format.getRawFormat();
        fmt.setExpandEmptyElements( false );
        fmt.setLineSeparator( LINEBREAK );

        output.setFormat( fmt );
        output.outputElementContent( m_document.getRootElement(), out );

        return out.toString();
    }
View Full Code Here

        channel.addContent( getItems() );

        //
        //  aaand output
        //
        XMLOutputter output = new XMLOutputter();

        output.setFormat( Format.getPrettyFormat() );

        try
        {
            StringWriter res = new StringWriter();
            output.output( root, res );

            return res.toString();
        }
        catch( IOException e )
        {
View Full Code Here

        root.addContent( getItems() );

        //
        //  aaand output
        //
        XMLOutputter output = new XMLOutputter();

        output.setFormat( Format.getPrettyFormat() );

        try
        {
            StringWriter res = new StringWriter();
            output.output( root, res );

            return res.toString();
        }
        catch( IOException e )
        {
View Full Code Here

                  targetDir.mkdir();
                }
                pomFile = new File(targetDir, "pom.xml");
               

                XMLOutputter out = new XMLOutputter( Format.getPrettyFormat() );
                out.output( doc, new FileOutputStream(pomFile));

            }

        } catch (IOException e) {
            getLog().warn(e);
View Full Code Here

   * Método responsável pela escrita no arquivo .cody.
   * @param doc  Dados a serem salvos no xml
   * @return    verdadeiro se conseguiu escrever, falso c.c. 
   */
  public boolean exportarArquivoXML(Document doc){
    XMLOutputter xout = new XMLOutputter();
    try {
          FileWriter arquivo = new FileWriter(new File(path));
          xout.output(doc, arquivo);
          return true;
    } catch (IOException e) {
          return false;
    }   
  }
View Full Code Here

    private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException {
        LinkedList<String> result = new LinkedList<String>();
        try {
            Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in));
            XMLOutputter out = new XMLOutputter();

            for (String xp : xpaths) {
                XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content());
                for (Content node : xpath.evaluate(doc)) {
                    if(node instanceof Element) {
                        result.add(out.outputString((Element) node));
                    } else if(node instanceof Text) {
                        result.add(out.outputString((Text) node));
                    }
                }
            }
            return result;
        } catch (JDOMException xpe) {
View Full Code Here

    private void save() {
        File f = FileManager.getAppFile(path);
        Element root = new Element("config");
        Document d = new Document(root);
        storeConfig(root, props);
        XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
        try {
            OutputStream os = new FileOutputStream(f);
            xo.output(d, os);
            os.close();
        } catch (IOException e) {
            throw new RuntimeException("Error saving config", e);
        }
    }
View Full Code Here

    public TestXMLOutputter() {
    super(true, true, false, false, false);
  }
   
    private XMLOutputter getOutputter(Format format) {
      return new XMLOutputter(format);
    }
View Full Code Here

TOP

Related Classes of org.jdom2.output.XMLOutputter

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.