1

I am trying to create a MS Word 2003 (.doc) file from an XML template. I am trying to replace my placeholders in the XML file with the content i want to insert in the word document. I have used the following code to replace the content:

Hashtable<String, String> ht = new Hashtable();
ht.put("NAME","XYZ");
ht.put("ROLL","123");       
while ((thisLine = reader.readLine()) != null) {
 if(thisLine.contains("##"))
 {
  for (java.util.Enumeration e = ht.keys(); e.hasMoreElements();) {
  String name = (String) e.nextElement();
  String value = ht.get(name).toString();
  thisLine = thisLine.replaceAll("##" + name.toUpperCase() + "##", value);
 }
}

##id## is my place holder in the XML file.

It runs properly when the placeholders are in a paragraph, but the problem with this code is that it does not replace the placeholders which are within a table in the XML word template.

So my question is how can I read the content of a table of an XML template using a simple java code so that I can replace the placeholders.

Sunmit Girme
  • 559
  • 4
  • 13
  • 30

0 Answers0