Java tutorial
//package com.java2s; //License from project: Apache License import java.util.UUID; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; public class Main { /** * Creates an empty node list. Creates an empty document then selects nodes * using a random UUID to ensure an empty result. * * @return an empty Node list */ public static NodeList createEmptyNodeList() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new IllegalStateException("Problem creating document", e); } Document document = builder.newDocument(); assert document != null; final NodeList emptyNodesList = document.getElementsByTagName(UUID.randomUUID().toString()); return emptyNodesList; } }