I have a input xml and want to generate another output xml taking this xml as an input.
I am trying this approch:
1) I parse the input xml and generate a object of it.
2) I create a template of output xml needed.
3) I parse the template xml and generate the
string represntation of the xml.
4) I use
Pattern and Matcher to replace the template node values with actual ones.
I have a template xml, with value of nodes substitued as
<name>${name}</name>
I parsed this template xml in
java and want to replace all occurances of ${name} based on the object generated from input xml
When I use this in my java class:
Pattern p = Pattern.compile("${name}");
Matcher m = p.matcher(strTemplate); // strTemplate has d template XML parsed
strReturn = m.replaceAll("John");
I am getting the follwing error:
java.util.regex.PatternSyntaxException: Illegal repetition near index 0
${name}
Can you help me in replacing the string ${name} with say John
Also heard using regular expression in a loop or more times is a serious perfomance hit. Can you let me know a better and efficient way to convert one form of xml to other?