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

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -