Java Utililty Methods XML Element from String

List of utility methods to do XML Element from String

  1. HOME
  2. Java
  3. X
  4. XML Element from String

Description

The list of methods to do XML Element from String are organized into topic(s).

Method

Element stringToElement(final String inputXml)
Convert XML string to Element.
try {
 final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
 final Document document = builder.parse(new ByteArrayInputStream(inputXml.getBytes("UTF-8")));
 return document.getDocumentElement();
} catch (ParserConfigurationException ex) {
 throw new IOException("IgapyonXmlUtil#stringToElement: Fail to configure xml parser: ", ex);
} catch (SAXException ex) {
 throw new IOException("IgapyonXmlUtil#stringToElement: Fail to process xml: ", ex);
...
Element stringToElement(String s)
Convert the String representation of an Element into an Element
return stringToElement(s, false);
Element stringToElement(String xml)
Converts a String representing an XML snippet into an org.w3c.dom.Element .
ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document d = builder.parse(bais);
bais.close();
return d.getDocumentElement();

AltStyle によって変換されたページ (->オリジナル) /