The XPath of Glory

2007-11-22 19:25:54

Should you ever need to work with XPath extensively, there's XPather for Firefox, that looks quite nice, but unfortunately I couldn't get it to work today, so I had to improvise. Then I stumpled across the very cool feature of xmllint, that lets you browse XML documents like directories.

$ cat test.xml
<body>
  <table><tr><td>a</td><td>b</td></tr></table>
  <div>
    <table><tr><td>c</td><td>d</td></tr></table>
  </div>
</body>

$ xmllint --shell test.xml
/ > cd //table[parent::div]/tr/td
td > ls
t--        1 d
td >

And to not be completely offtopic, I'll admit that once I got my XPath expressions, I fed them to SimpleXML

About

Life's a bitch, life's a whore. Nothing less, nothing more.

Read More