Test::XPath

Test XML and HTML content and structure with XPath expressions
Download

Test::XPath Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David E. Wheeler
  • Publisher web site:
  • http://search.cpan.org/~dwheeler/

Test::XPath Tags


Test::XPath Description

Test XML and HTML content and structure with XPath expressions Use the power of XPath expressions to validate the structure of your XML and HTML documents.Synopsis use Test::More tests = > 5; use Test::XPath; my $xml = < < 'XML'; < html > < head > < title >Hello< /title > < style type="text/css" src="foo.css" >< /style > < style type="text/css" src="bar.css" >< /style > < /head > < body > < h1 >Welcome to my lair.< /h1 > < /body > < /html > XML my $tx = Test::XPath- >new( xml = > $xml ); $tx- >ok( '/html/head', 'There should be a head' ); $tx- >is( '/html/head/title', 'Hello', 'The title should be correct' ); # Recursing into a document: my @css = qw(foo.css bar.css); $tx- >ok( '/html/head/style', sub { my $css = shift @css; shift- >is( './@src', $css, "Style src should be $css"); }, 'Should have style' ); # Better yet, use PerlX::MethodCallWithBlock: use PerlX::MethodCallWithBlock; my @css = qw(foo.css bar.css); use PerlX::MethodCallWithBlock; $tx- >ok( '/html/head/style', 'Should have style' ) { my $css = shift @css; shift- >is( './@src', $css, "Style src should be $css"); }; Requirements: · Perl


Test::XPath Related Software