http://www.perlmonks.org?node_id=998730


in reply to Re^4: XML::Simple XML / XMLin / XMLout? or something else?
in thread XML::Simple XML / XMLin / XMLout? or something else?

:-))

Yes, of course! That's why I wrote that I can't resist.

It was just how the initial question was formulated: I couldn't see if xml has to be parsed to work on the parsed data. Then his own approach would have been sufficient. The only problem I could see was the loss of element order. The other thing what I could see is a kind of extraction. But be aware: The resulting xml-snippets concatenated together don't form valid XML. XML mandates that you have to have one starting and ending tag containing all other tags. So the wished output is not valid XML. So, what is it good for? (He gave the answer meanwhile. This little add on let all others know the intention.)

So, if you don't need real XML parsing and you know the structure and layout of incoming XML you can do many things without parsing. To your example of having NO newlines:

xmllint --format data1.xml | perl -ne 'print unless /booklist|\?xml /'

Not perl related, but probably useful for Roboz while debugging his SOAP stuff: xmllint is an excellent command line tool (commonly in package libxml2). I hope that this last hint will be valueable at least :-))

Best regards
McA