Hacker Public Radio

HPR3394: Be an XML star with xmlstarlet


Listen Later

See the layout of an XML document
$ xmlstarlet elements planets.xml
xml
xml/sol
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
See content of the planet node
$ xmlstarlet select -t --value-of '/xml/sol/planet' planets.xml
Mercury
0.11
Venus
0.7
Terra
0.39
Get the third instance of the planet node
$ xmlstarlet select -t --value-of '/xml/sol/planet[3]' planets.xml
Terra
0.39
Get only the planets with an albedo greater than 0.25
$ xmlstarlet select -t --value-of '/xml/sol/planet[albedo > 0.25]' planets.xml
Venus
0.7
Terra
0.39
Get only the planets closer to Sol than the third planet
$ xmlstarlet select -t --value-of '/xml/sol/planet[position() < 3]' planets.xml
Mercury
0.11
Venus
0.7
Learn more XPath functions at Mozilla Developer Network.
Download xmlstarlet from xmlstarlet.sourceforge.net.
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Infinite Monkey Cage by BBC Radio 4

The Infinite Monkey Cage

1,952 Listeners

Click Here by Recorded Future News

Click Here

418 Listeners

Hacker And The Fed by Chris Tarbell & Hector Monsegur

Hacker And The Fed

168 Listeners