2013-10-21 36 views
0

我想打印出HTML頁上的XML文件。 我使用引入nokogiri有:用Nokogiri打印XML(在Padrino中),並具有良好的縮進

Nokogiri::XML::DocumentFragment.parse("<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>").to_xml(:indent => 2) 

,但我的HTML頁面上我得到了:

<note> 
        <to>Tove</to> 
        <from>Jani</from> 
        <heading>Reminder</heading> 
        <body>Don't forget me this weekend!</body> 
        </note> 

代替

<note> 
     <to>Tove</to> 
     <from>Jani</from> 
     <heading>Reminder</heading> 
     <body>Don't forget me this weekend!</body> 
    </note> 

我打印出來與padrino逃生功能(html_escape) 。

這似乎是該功能產生的問題,因爲在控制檯中一切都正確打印。

你能幫我解決這個問題嗎?我試圖找到一些答案,但我沒有找到任何東西。

回答

0

我找到了答案。這是HAML的問題,所以下次你想打印出XML或與html_escape另一個源代碼之前的時間,加上

= preserve do 
    &= escaped_source 

,一切都會正常縮進。

相關問題