Java tutorial
//package com.java2s; /*! * AtlantBH Custom Jmeter Components v1.0.0 * http://www.atlantbh.com/jmeter-components/ * * Copyright 2011, AtlantBH * * Licensed under the under the Apache License, Version 2.0. */ import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.Document; import org.xml.sax.InputSource; public class Main { private static DocumentBuilder builder; /** * Convert string to XML {@link Document} * * @param string - string to be converted * @return - {@link Document} * @throws Exception - if {@link DocumentBuilder} is not initialized */ public static Document stringToXml(String string) throws Exception { if (builder == null) { throw new Exception("DocumentBuilder is null."); } return builder.parse(new InputSource(new ByteArrayInputStream(string.getBytes("UTF-8")))); } }