Common GNU tools (wget, grep, ...) are assumed.


Use the Slashdot backend.

% wget -q -O - http://slashdot.org/slashdot.xml | xml2
/backslash/story/title=More on Athlon Overclocking
/backslash/story/time=2000-03-05 03:40:47
/backslash/story/title=New Atari Jaguar Game Running $1,225 on eBay

Now, just the headlines.

% wget -q -O - http://slashdot.org/slashdot.xml | xml2 | 
  grep story/title= | cut -d= -f 2-
More on Athlon Overclocking
New Atari Jaguar Game Running $1,225 on eBay
AT&T's Korn Shell Source Code Released
TheBench.org: Community Cartooning
OpenGL for Palm OS Environment
Banner Ads on Your Cell Phone
Burning Money on Open Source
Embedded OpenBSD Running the Stallion ePipe
Bezos Responds to Tim O'Reilly's Open Letter
Update on 'Blame Canada' and the Oscars

How big is the Red Hat 6.1 libxml RPM?

(For variety, we use awk rather than grep and cut.)
% wget -q -O - http://rpmfind.net/linux/RDF/redhat/6.1/i386/libxml-1.4.0-1.i386.rdf | 
  xml2 | awk -F= '/RPM:Size/ {print $2}'

What is the melting point of silicon?

More awkitude. Don't let your CPU get hotter than this!
% wget -q -O - http://metalab.unc.edu/xml/examples/periodic_table/allelements.xml | 
  xml2 | awk '/ATOM\/NAME=Silicon/,!/ATOM\//' | 
         awk -F\= '/MELTING_POINT/ {print $2}'
(1683K is 2570F, by the way.)


Fetch the Slashdot news page.

You'll probably see some warnings. (Slashdot has some of the worst HTML I've ever seen...)
% wget -q -O - http://slashdot.org/ | html2
/html/head/title=Slashdot:News for Nerds. Stuff that Matters.

Find all the links.

If you find the warnings distracting, redirect the standard error of html2 to /dev/null.
% wget -q -O - http://slashdot.org/ | html2 | grep 'a/@href' | 
  cut -d\= -f 2- | sort | uniq

Change some colors.

This pipeline uses both html2 and 2html to effect a round-trip. In the middle, sed applies a transformation, turning the background of every colored table on the page yellow. Yuck, huh?
% wget -q -O - http://slashdot.org/ | 
  html2 | sed 's|table/@bgcolor=\(.*\)$|table/@bgcolor=yellow|' | 
  2html > slashdot.html
% netscape slashdot.html

Strip JavaScript from a Geocities home page.

Geocities uses JavaScript to create an annoying little brand popup in the corner of their members' home pages. Let's delete it.
% wget -q -O - http://www.geocities.com/SiliconValley/Peaks/5957/xml.html | 
  html2 | grep -vi '^[^=]*/script[/=]' | 
  2html > xml.html
% netscape xml.html

XML/Unix Processing Tools