Posted By

bsrinivasan92 on 01/31/12


Tagged


Versions (?)

split.rb


 / Published in: Ruby
 

split

  1. require "rexml/document"
  2. include REXML
  3. file=File.open('<filename>.xml')
  4. f=file.read()
  5.  
  6. parts=f.split('<?xml')
  7. Dir.mkdir("docs")
  8. counter=0
  9. parts.reverse!.pop
  10. parts.reverse!
  11. parts.each { |part|
  12. counter=counter+1
  13. out=File.new("./docs/#{counter}.xml", 'w')
  14. out.puts("<?xml #{part}")
  15. #find filename
  16. }

Report this snippet  

You need to login to post a comment.