in reply to XML Parsing question
So here's a one-liner that does what you want via XML::Parser:
(Note that the quotes as shown are based on using a bash shell or equivalent -- not ms-dos/cmd.exe.)perl -MXML::Parser -e '$p=XML::Parser->new(Handlers=>{Char=>sub{print +"$_[1] "}}); $p->parsefile("filename.xml")'
If the amount and types of white-space you get from that are not to your liking, you could either complicate the one-liner a little bit (add tr/ \n/ /s in the sub{}), or just pipe the output to another one-liner...
(updated last paragraph to improve the "tr///" suggestion; to clarify, here's a "really tidy" version of the one-liner:
which puts all the visible text on one line, then adds a final line-feed.)perl -MXML::Parser -e '$p=XML::Parser->new(Handlers=> {Char=>sub{($_=$_[1])=~tr/ \n/ /s; s/^ +$//; print}}); $p->parsefile("filename.xml"); print "\n"'
|
|---|