* Mike Frysinger ([EMAIL PROTECTED]) wrote: > On Friday 07 September 2007, Alec Warner wrote: > > On 9/7/07, Doug Goldstein <[EMAIL PROTECTED]> wrote: > > > Sure... be fancy with all your xsl and xml crap. LONG LIVE THE BRUTE > > > FORCE PARSE WITH SED! > > > > People who parse xml with sed make me cry. > > > > grep = also bad. > > i'd parse it with xmlgawk if i hadnt punted it from gawk sometime ago > -mike
app-text/xml2 makes a surprisingly nice replacement for xmlgawk for people who know not to use sed or awk on XML, yet still want to. For example: $ xml2 < /var/lib/repos/gentoo/sys-apps/busybox/metadata.xml \ | awk -F= '/\/herd=/ {print $2}' embedded $ xml2 < /var/lib/repos/gentoo/www-client/surfraw/metadata.xml \ | sed '/\/maintainer\/email=/!d;s,^.*=,,' [EMAIL PROTECTED] [EMAIL PROTECTED] or to match Vapier's output just collapse the output: $ echo $(xml2 < /var/lib/repos/gentoo/www-client/surfraw/metadata.xml \ | awk -F '/\/maintainer\/email=/ {print $2}') [EMAIL PROTECTED] [EMAIL PROTECTED] The above examples will cope with cases that will break the simple sed version, such as "<herd>\ndata\n</herd>". But then again so does Vapier's xsltproc solution. As a hint for other tasks the package can cope with tagsoup too if called with html2, and it can reassemble with 2xml/2html. There is some documentation online at the author's website, but its usage is obvious. Thanks, James
pgpBdXSAzSX3x.pgp
Description: PGP signature