How could I read a properties file and insert data into XML file?

May this should be a good start: File xmlfile = null; File propertiesfile = null; Properties p = new Properties(); p. Load(new FileReader(propertiesfile)); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf. NewDocumentBuilder(); Document parse = db.

Parse(xmlfile); DOMSource domSource = new DOMSource(parse); Node root = domSource.getNode(); for (Object key : p.keySet()) { String sKey = "" + key; root. SetTextContent(root.getTextContent()+sKey + "=" + p. GetProperty(sKey)); } TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); transformer.

Transform(domSource, new StreamResult(xmlfile)).

Unless you have to do this repeatedly, I'd use this ancient programming technique: Open properties file ghlight a property in properties file Ctrlc Open hibernate config xml file Locate insert carat at place of property value Ctrlv.

Correct, but useless --- Oh even not correct: this is not configuration – Ralph Jul 28 at 6:18.

If I understand the documentation right, it should be work out of the box: 7. XML configuration file An alternative approach to configuration is to specify a full configuration in a file named hibernate.cfg.xml. This file can be used as a replacement for the hibernate.

Properties file or, if both are present, to override properties. So you only need the hibernate properties file and the hibernate.cfg.xml. If you do not set the values in hibernate.cfg.

Xml, then they are taken from the properties file. -- I did not proved that, but that is the way I understand the documentation.

I have the xml file, but data from database, user and password I would like to read it from properties file and load it in XML file – Jose Hdez Jul 28 at 6:31 @Jose Hdez: yes that is what I am talking about: do not add this 3 properties to the hibernate.cfg. Xml, instead put it in the hibernate. Properties file – Ralph Jul 28 at 6:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions