Code example for DOMSource

Methods: setNode

0
 * 
 */ 
public class ConfigHelper { 
 
	public Object getAllSchemaPathNames(String basePath) throws ParserConfigurationException, XPathExpressionException{
		DOMSource ds = new DOMSource();
		 
		DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
	    DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
 
	    Document newDoc = domBuilder.newDocument();
	    Element rootElement = newDoc.createElement("schemas");
	    newDoc.appendChild(rootElement);
	     
	    Element element = null;
	    /*for(String member : unionMemberTypes.split(" ")){ 
	    	element = newDoc.createElement("name"); 
		    element.setTextContent(member); 
		    rootElement.appendChild(element); 
	    }*/ 
	     
	    ds.setNode(newDoc);
	     
	    XPathExpression xpe = XPathFactory.newInstance().newXPath().compile("/");
	    Object expRes = xpe.evaluate(newDoc, XPathConstants.NODESET);
	     
		return expRes;
Experience pair programming with AI  Get Codota for Java