how to remove Xml version string from String
java
Solution
Change your regular expression to
XmlString=XmlString.replaceAll("\\<\\?xml(.+?)\\?\\>", "").trim();
Problem
I have read Xml File using code given below- ``` String XmlString = ""; String resourcePath=FilePathHelper.getResourceFilePath(request); BufferedReader br = new BufferedReader(new FileReader(new File(resourcePath+ "SubIndicatorTemplate.xml"))); String line; StringBuilder sb = new StringBuilder(); while((line=br.readLine())!= null){ sb.append(line.trim()); } XmlString=sb.toString(); ``` Now i get XmlString sting in the format given below- ``` <?xml version="1.0" encoding="UTF-8" standalone="no"?><Template><Caption Name="Book Details"/><Data Type="one"/><Titles><Title Name="Book no" Type="Numeric"/><Title Name="Book name" Type="Text"/></Titles></Template> ``` I want to remove `<?xml version="1.0" encoding="UTF-8" standalone="no"?>` from above string.So i have written code as ``` XmlString=XmlString.replaceAll("<?xml*?>", "").trim(); ``` But still XmlString are same. So please help me to remove version information from XmlString.