Coldfusion - XML ​​Pretty Print

There are many ways to print XML, but I still need to find the ColdFusion function.

This is a general question, but again I want to do it in ColdFusion.

+3
source share
4 answers

A quick search on http://cflib.org included xmlIndent () .

<pre>#xmlIndent(xmlString)#</pre>
+3
source

see top answer: Enough to print XML using javascript . Try using XmlTransform(). If it does not work, select the Java XSLT engine, for example http://saxon.sourceforge.net/ , as suggested

+1
source

Java- XOM, , . Java:

<cfset xmlString = [your xml here]/>

<cfscript>
encoding = "ISO-8859-1";
parser = createObject("java", "nu.xom.Builder").init();
doc = parser.build(xmlString);
out = createObject("java", "java.io.ByteArrayOutputStream").init();
Serializer serializer = new Serializer(out, encoding);
// bunch of options
serializer.setIndent(4);
serializer.setMaxLength(64);
serializer.setPreserveBaseURI(true);

serializer.write(doc);
serializer.flush();
</cfscript>

<cfoutput>#out.toString(encoding)#</cfoutput>
0

Use prettydiff.com/markup_beauty.js. If it is capable of supporting invalid markup, snippets, and JSTL code, it should be able to handle CFML without any workloads. Consider the following example of a complex JSTL tag.

<c:out value="<strong>text</strong>"/>

You can demonstrate this application using the web tool at prettydiff.com . Just select the "beautify" and "markup" options.

0
source

Source: https://habr.com/ru/post/1772031/


All Articles