Java XML String Transform toElement(String xml)

Here you can find the source of toElement(String xml)

Description

to Element

License

Open Source License

Declaration

public static Element toElement(String xml) 

Method Source Code


//package com.java2s;
import java.io.StringReader;

import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static Element toElement(String xml) {
        DOMResult dom = new DOMResult();
        try {//w  w w .java  2s  . com
            TransformerFactory.newInstance().newTransformer().transform(new StreamSource(new StringReader(xml)),
                    dom);
        } catch (Exception e) {
        }

        return ((Document) dom.getNode()).getDocumentElement();
    }
}

Related

  1. signEmbeded(Node doc, String uri, PrivateKey pKey, X509Certificate cert)
  2. String2Doc(String InputXMLString)
  3. string2Source(String xml)
  4. stringToNode(String s)
  5. strToSchema(final String strXsd)
  6. toHexString(byte[] array)
  7. toHTML(String xml)
  8. toJson(String xml)
  9. toLCCNDisplay(String packedLCCN)