Source:
<code>public String toXmlForEmbed( String rootTag ) { BeanMap m = new BeanMap( this ); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; Document doc = null; try { builder = dbf.newDocumentBuilder(); doc = builder.newDocument(); Element rootNode = doc.createElement( rootTag ); doc.appendChild( rootNode ); StringBuilder sb = new StringBuilder(); @SuppressWarnings( "unchecked" ) Iterator<Map.Entry<Object, Object>> i = m.entryIterator(); while ( i.hasNext() ) { Map.Entry<Object, Object> entry = i.next(); String elementName = (String) entry.getKey(); if ( !"class".equals( elementName ) && !"parentVariableSpace".equals( elementName ) ) { String value = ""; String type = "String"; Object o = entry.getValue(); if ( o != null ) { if ( o instanceof Long ) { value = Long.toString( (Long) o ); } else if ( o instanceof Boolean ) { value = Boolean.toString( (Boolean) o ); } else { try { value = (String) entry.getValue(); if ( elementName.toLowerCase().contains( "password" ) ) { value = passwordEncoder.encode( value ); } } catch ( Exception e ) { e.printStackTrace(); } } } rootNode.appendChild( createChildElement( doc, elementName, type, value ) ); } } DOMSource domSource = new DOMSource( doc ); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult( writer ); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform( domSource, result ); String s = writer.toString(); s = s.substring( s.indexOf( ">" ) + 1 ); <START> return s; <END> } catch ( ParserConfigurationException | TransformerException e1 ) { e1.printStackTrace(); return ""; } }</code><technical_language>is this doing? Removing <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ?</technical_language>

Target:
public String toXmlForEmbed( String rootTag ) { BeanMap m = new BeanMap( this ); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; Document doc = null; try { builder = dbf.newDocumentBuilder(); doc = builder.newDocument(); Element rootNode = doc.createElement( rootTag ); doc.appendChild( rootNode ); StringBuilder sb = new StringBuilder(); @SuppressWarnings( "unchecked" ) Iterator<Map.Entry<Object, Object>> i = m.entryIterator(); while ( i.hasNext() ) { Map.Entry<Object, Object> entry = i.next(); String elementName = (String) entry.getKey(); if ( !"class".equals( elementName ) && !"parentVariableSpace".equals( elementName ) ) { String value = ""; String type = "String"; Object o = entry.getValue(); if ( o != null ) { if ( o instanceof Long ) { value = Long.toString( (Long) o ); } else if ( o instanceof Boolean ) { value = Boolean.toString( (Boolean) o ); } else { try { value = (String) entry.getValue(); if ( elementName.toLowerCase().contains( "password" ) ) { value = passwordEncoder.encode( value ); } } catch ( Exception e ) { e.printStackTrace(); } } } rootNode.appendChild( createChildElement( doc, elementName, type, value ) ); } } DOMSource domSource = new DOMSource( doc ); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult( writer ); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform( domSource, result ); String s = writer.toString(); s = s.substring( s.indexOf( ">" ) + 1 ); return s; } catch ( ParserConfigurationException | TransformerException e1 ) { LOGGER.error( "Could not parse embedded cluster xml" + e1.toString() ); return ""; } }