Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Adding An XML Declaration To A REXML Document

DZone's Guide to

Adding An XML Declaration To A REXML Document

·
Free Resource
Source: REXML Tutorial - Home [germane-software.com]


 
  
REXML will not, by default, write out the XML declaration unless you specifically ask for them. If a document is read that contains an XML declaration, that declaration will be written faithfully. The other way you can tell REXML to write the declaration is to specifically add the declaration:
Adding an XML Declaration to a Document

  
doc = Document.new 
doc.add_element 'foo'
doc.to_s   #-> 
   
doc << XMLDecl.new
doc.to_s   #-> 
   
   


 
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}