xml file formatting from entire file in single string

  • Thread starter David Southwell
  • Start date
D

David Southwell

Hi

Anyone have or can point me to a snippet that will convert an entire xml file
in the form of a continuous string into a well formatted file?

Thanks

David
 
P

Phrogz

Anyone have or can point me to a snippet that will convert an entire xml file
in the form of a continuous string into a well formatted file?

Slim2:~ phrogz$ irb
rirb(main):001:0> require 'rexml/document'
=> true

irb(main):002:0> doc = REXML::Document.new "<root><foo bar='12'>yow</
foo></root>"
=> <UNDEFINED> ... </>

irb(main):003:0> doc.to_s
=> "<root><foo bar='12'>yow</foo></root>"

irb(main):004:0> doc.write( $stdout, 2 )
<root>
<foo bar='12'>
yow
</foo>
</root>
=> [<?xml ... ?>, <root> ... </>]

irb(main):005:0> doc.write( $stdout, 4 )
<root>
<foo bar='12'>
yow
</foo>
</root>
=> [<?xml ... ?>, <root> ... </>]

For more, see: http://www.germane-software.com/software/rexml/docs/tutorial..html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top