|
|
Finding best way to pretty print XML files
Havn't found best soultion to pretty print XML:
REXML: It has pp functionality, but it wrap elements like <a>content</a>
to
<a>
content
</a>
Nokogiri: there is a approch to pp, see ex:
# Pretty print XML
require "nokogiri"
def write(buffer)
xsl =<<XSL
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
XSL
doc = Nokogiri::XML(buffer)
xslt = Nokogiri::XSLT(xsl)
out = xslt.transform(doc)
out.to_xml
end
But nokogiri has another problem, which unwrap CDATA.
Any better solution? Thanks. And apologize for my poor english.
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Pk
|
1/11/2011 7:35:56 AM |
|
0 resp. ToT
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Pk
|
1/12/2011 12:53:30 AM
|
|
Sorry if you haven't got any help,
could you provide more informations to the output you want ?
There are many ways to indent XML code. Maybe you don't want to wrap lines
with <a>content</a>, but what if the content is longer ? Do you have a
column limit ?
In your place, I would take the pp code of nokogiri and tweak it until it
gives me what I want.
Hope that help,
zimbatm
2011/1/12 Pk Z. <k@z-pk.com>:
> 0 resp. =C2=A0ToT
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
|
|
0
|
|
|
|
Reply
|
Jonas
|
1/12/2011 11:18:50 PM
|
|
[Note: parts of this message were removed to make it a legal post.]
In my experience, everyone has a different definition of "pretty printing".
If you want to get more specific about what you'd like to see, perhaps
people can give you a more specific answer.
On Tue, Jan 11, 2011 at 7:53 PM, Pk Z. <k@z-pk.com> wrote:
> 0 resp. ToT
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
|
|
0
|
|
|
|
Reply
|
Mike
|
1/13/2011 12:05:12 AM
|
|
|
3 Replies
357 Views
(page loaded in 0.055 seconds)
Similiar Articles: excelxp tagset and data type in xml - comp.soft-sys.sasHi, I am pretty new to the excelxp taget world, but am finding my way. My current prob is I am using a proc print, the member_var ... like this through to your XML file ... Help to 'pretty'; replace WITHIN file without TEMP file?? - comp ...... it's def. not my best coding =P AWK can do in-file ... this can trash files. awk "{print $ ... lang.awk Help to 'pretty'; replace WITHIN file without TEMP file?? - comp ... Find ... Finding environment variables usage - comp.unix.programmer ...In Perl you should print a list of all of them ... The best way is to analyse the data flow in the ... strip file path and file extension from a file name in a ... Finding ... makeing changes to a file with awk - comp.lang.awk... length as the original) is fudging in one way ... what the original encoding of the XML file was. But ... Help to 'pretty'; replace WITHIN file without TEMP file?? - comp ... ... Some text processing questions - comp.lang.vhdl... www.stefanvhdl.com/vhdl/vhdl/txt_util.vhd) pretty ... Simple XML processing in AWK - comp.lang.awk. Best way to touch up PDF files? - comp.text.pdf recommended speech ... Acrobat -- extracting pages as separate pdf files - comp.text.pdf ...... at 4am) whether acrobat could print a page of a document to a specific file as a pdf. ... reviews and programming about XML Paper ... Therefore, for me the best way to automize ... Wireframe rendering? - comp.cad.solidworksWhat's the best way to get a ... free download, you'll find it readily via Google) 1.) Print your SW view to a PDF file 2.) ... next step rendering the XML into one of the file ... Can I customize figure toolbar item? - comp.soft-sys.matlab ...The easiest way would be to accept the existence of ... I find the figure toolbar pretty useful (panning, zooming ... ... the following kinds of tasks in a Schema.xml file to ... Misuses of RTTI - comp.lang.c++.moderatedThis rule looks harsh, but it pretty much ... require 20 > years to figure out the best way to ... which serializes them in different ways to files, memory, console, xml etc ... /usr/local/lib - ln or LD_LIBRARY_PATH - comp.unix.solaris ...Whats the best way to ensure these libraries are found at ... g., forking off a copy of "/usr/bin/lp" to print ... ISTR that the "configure" file takes a "help" argument ... XML Programming in C# and .NET - C#, Visual Studio 2010 ....NET Remoting in C# Coding Best Practices ... In this section, you will find various XML .NET related ... Different ways of reading an XML file Tip: Command-line XML processing - IBM - United States... flat text files enjoy; XML developers just need to learn from experience the best ways to ... moderately pretty way to do this). For data-oriented XML ... Print this page ... 7/21/2012 9:44:54 PM
|
|
|
|
|
|
|
|
|