hi i've this little method:
private void modifyXML() {
try {
String filepath = main.fileWithPath;
File f = new File(filepath);
if(f.exists()){
System.out.println("Exists");
}
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(filepath);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("DAQChannel");
// int sorszam = table.row_id-1;
//
// Node nNode = nList.item(sorszam);
//
// if (nNode.getNodeType() == Node.ELEMENT_NODE) {
// Element eElement = (Element) nNode;
//
// eElement.getElementsByTagName("Name").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("Unit").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("Minimum").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("Maximum").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("Accuracy").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("SensorType").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("RegisterAddress").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("Offset").item(0).setTextContent(nameE.getText().toString());
// eElement.getElementsByTagName("TimeStamp").item(0).setTextContent(nameE.getText().toString());
// }
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
String ujPath = filepath.substring(0, filepath.length()-10);
StreamResult result = new StreamResult(new File(ujPath+"/config_midified_"+mydate+".xml"));
transformer.transform(source, result);
System.out.println("Done");
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (TransformerException tfe) {
tfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (SAXException sae) {
sae.printStackTrace();
}
}
it prints out that the file exists right in the begining, but than i got the error message java.net.MalformedURLException: Protocol not found:
Please help me what did i wrong!
Thank you!