how to display xml formatted jsp -
i have xml string in jsp. xml in single line. want display xml string formatted in jsp.
for example:
<?xml version="1.0"?><catalog><book id="bk101"><author>gambardella, matthew</author><title>xml developer's guide</title><genre>computer</genre><price>44.95</price>...(is going on) i want display follows in jsp:
<?xml version="1.0"?> <catalog> <book id="bk101"> <author>gambardella, matthew</author> <title>xml developer's guide</title> <genre>computer</genre> <price>44.95</price>...(going on) how can this?
i have exact same problem. solved formatting xml string in java code before sending jsp (you can in jsp if want):
transformer transformer = transformerfactory.newtransformer(); transformer.setoutputproperty(outputkeys.indent, "yes"); source source = new domsource(document); stringwriter writer = new stringwriter(); result output = new streamresult(writer); transformer.transform(source, output); return writer.tostring(); then use c:out display it
<pre> <c:out value="${xmlstring}" /> </pre>
Comments
Post a Comment