I am trying to save nodeList
node that contains XML
as a new file, here is the Node list that get a new XML
doc and split to smaller XMLs
:
public void split(Document inDocument) throws ParserConfigurationException,
SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
SaveXML savePerJob = new SaveXML();
// Load the input XML document, parse it and return an instance of the
// Document class.
Document document = inDocument;
//all elements
//jobs
NodeList nodes = document.getDocumentElement().getChildNodes();
NodeList jobs = nodes.item(7).getChildNodes();
for(int j =0; j<jobs.getLength(); j++){
Node itm = jobs.item(j);
String itmName = itm.getFirstChild().getNodeName();
String itmID = itm.getFirstChild().getTextContent();
System.out.println("name: " + itmName + " value: " + itmID);
//here I want to save the node as a new .xml file
}
}
the output is a long list like :
name: id value: 9496425
Now I want to save the node itm
as new new .xml
file and I didnt find the function that returns the node as is.
Thanks.