0
votes

I am building XML with Nokogiri with the option of not having empty tags:

doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)

It indeed works for removing empty tags, however passing this option to to_xml removes all of my indentation, new line characters etc.

Is there a way to tell Nokogiri to same with NO_EMPTY_TAGS but keeping the rest of the defaults?

Help is kindly appreciated!

1

1 Answers

1
votes

You can perform an or operation on your options' bits.

doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)

This will apply the defaults of AS_XML and the additional setting of NO_EMPTY_TAGS