ruby - Nokogiri XSLT tagging document as XML type when using JSON -


i using nokogiri transform xml document json. code straight forward:

@document = nokogiri::xml(entry.data) xslt = nokogiri::xslt(file.read("#{file.dirname(__file__)}/../../xslt/my.xslt")) transform = xslt.transform(@document) 

entry in case mongoid based model , data xml blob attribute stored string on mongodb.

when dump contents of transform, json there. problem is, nokogiri tagging top of document with:

<?xml version="1.0"?> 

what's correct way of addressing that?

try #apply_to method below(source):

require 'nokogiri'  doc  = nokogiri::xml('<?xml version="1.0"><root />') xslt = nokogiri::xslt("<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/xsl/transform'/>") puts xslt.transform(doc) puts "######" puts xslt.apply_to(doc)  # >> <?xml version="1.0"?> # >> ###### # >>  

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -