I\'ve created an XML template in ERB. I fill it in with data from a database during an export process.
In some cases, there is a null value, in which case an element
A couple questions:
is the same as
, so why worry about such a tiny detail? If it is syntactically significant because the text node between the two is a "\n"
, then put a test in your ERB template that checks for the value that would go there, and if it's not initialized output the self-closing tag instead? See "Yak shaving".EDIT - Nokogiri's behavior is to not-rewrite parsed XML unless it has to. I suspect you'd have to remove the node in question, then reinsert it as an empty node to get Nokogiri to output what you want.