Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^5: XML::Simple XML / XMLin / XMLout? or something else?

by McA (Priest)
on Oct 12, 2012 at 15:51 UTC ( #998730=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998730]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-11-21 21:28 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (312 votes). Check out past polls.