Reading XML: Introducing XPath

Reading XML: Introducing XPath

Andrew Walker

Why?

? Makes writing analysis scripts for your XML encoded results easy.

? Is used by many other XML technologies. XSLT, XPointer etc.

? A Fortran XPath API is in development. ? It helps you design your XML documents.

#! /usr/bin/perl -w $num = `[+-]?\d+\.?\d*'; while () {

if (/temperature = ($num)/) { $temp = $1;

} elsif (/pressure = ($num)/) { $pres = $1;

} } ...

#! /usr/bin/perl -w

use XML::XPath;

my $xp = XML::XPath ->new(filename => $ARGV[0]);

$temp = $xp -> find("//temperature");

$pres = $xp -> find("//pressure");

...

/XPath/queries/are/like/paths

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download