java - Unindent or linearize XML -
i'm looking fast way linearize xml in java
i'm using ~2gb file dom excluded. java targhet 1.5.0.22 have generate xml file composed of 80bytes + newline read file byte byte(i must) can use internal temp bufferization store sequence ignore
example 5 bytes af ascii file
<a><b><c>psofpisogiosigpsfiogpo</c></b></a> <a><b ><c>p sofpi sogio sigps fiogp o</c> </b>< /a>
problem file
<a> <b> <c>psofpisogiosigpsfiogpo</c> </b> </a> <a> <b > <c>ps ofpis ogios igpsf iogpo </c> < /b> </ a>
if can linearize file same output if file indented or not
any idea?
private static final string xml_linarization_regex = "(>|>){1,1}(\\t)*(\\n|\\r)+(\\s)*(<|<){1,1}"; private static final string xml_linarization_replacement = "$1$5"; public static string linarizexml(string xml) { return (xml!= null) ? xml.trim().replaceall(xml_linerization_regex, xml_linerization_replacement) : null; }
Comments
Post a Comment