Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > xml file formatting from entire file in single string

Reply
Thread Tools

xml file formatting from entire file in single string

 
 
David Southwell
Guest
Posts: n/a
 
      11-03-2009
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

 
Reply With Quote
 
 
 
 
Jordi Bunster
Guest
Posts: n/a
 
      11-03-2009


 
Reply With Quote
 
 
 
 
Sven Schott
Guest
Posts: n/a
 
      11-03-2009
[Note: parts of this message were removed to make it a legal post.]

I know it's hardly a snippet but, tidy?

http://tidy.rubyforge.org/

On Wed, Nov 4, 2009 at 9:46 AM, David Southwell <(E-Mail Removed)>wrote:

> 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
>
>


 
Reply With Quote
 
Phrogz
Guest
Posts: n/a
 
      11-04-2009
On Nov 3, 3:46*pm, David Southwell <(E-Mail Removed)> wrote:
> 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:ocument.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/soft...tutorial..html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for string, then extract entire XML element where it appears. How? mandibdc@gmail.com XML 6 07-03-2006 01:54 AM
Passing entire file to a variable in a single command solutions@gmail.com Perl Misc 4 07-07-2005 09:10 PM
Formatting a single line without effecting the entire table with the Text::Table module Mothra Perl Misc 10 03-11-2005 03:56 PM
Best Design: user controls, single class, etc. for entire site Jordan ASP .Net 1 10-20-2004 02:59 PM



Advertisments