I am getting XML data from a URL and from that data I'm generating my xml for the needed values. Now everything works perfect, but I need to add 3 lines of code at the start of my document.
<#setting time_zone="UTC">
<#assign day=.now?string("dd")?number>
<#assign hour=.now?string("HH")?number>
Does anyone know how to add this without real performance issues (e.g. opening the document again and altering the text at the beginning). Or is this the only way?
As I'm using org.w3c.dom.* I was wondering if this is possible on an easy way :)
Some code I have
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("wx");
doc.appendChild(rootElement);
Element metar = doc.createElement("metar");
metar.appendChild(doc.createTextNode("testMet"));
rootElement.appendChild(metar);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
Thanks!
No comments:
Post a Comment