Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

test::xml::simple(3pm) [debian man page]

Test::XML::Simple(3pm)					User Contributed Perl Documentation				    Test::XML::Simple(3pm)

NAME
Test::XML::Simple - easy testing for XML SYNOPSIS
use Test::XML::Simple tests=>5; xml_valid $xml, "Is valid XML"; xml_node $xml, "/xpath/expression", "specified xpath node is present"; xml_is, $xml, '/xpath/expr', "expected value", "specified text present"; xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present"; xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match"; # Not yet implemented: # xml_like_deeply would be nice too... DESCRIPTION
"Test::XML::Simple" is a very basic class for testing XML. It uses the XPath syntax to locate nodes within the XML. You can also check all or part of the structure vs. an XML fragment. TEST ROUTINES
xml_valid $xml, 'test description' Pass an XML file or fragment to this test; it succeeds if the XML (fragment) is valid. xml_node $xml, $xpath, 'test description' Checks the supplied XML to see if the node described by the supplied XPath expression is present. Test fails if it is not present. xml_is_long $xml, $xpath, $value, 'test description' Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::More's "is" function to do the comparison. xml_is $xml, $xpath, $value, 'test description' Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::LongString's "is_string" function to do the test. xml_like_long $xml, $xpath, $regex, 'test description' Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::More's "like" function to do the comparison. xml_like $xml, $xpath, $regex, 'test description' Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::LongString's "like_string" function to do the test. xml_is_deeply_long $xml, $xpath, $xml2, 'test description' Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::More's "is" function to do the comparison. xml_is_deeply $xml, $xpath, $xml2, 'test description' Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::LongString's "is_string" function to do the test. AUTHOR
Joe McMahon, <mcmahon@cpan.org> LICENSE
Copyright (c) 2005 by Yahoo! and Joe McMahon This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available. SEE ALSO
XML::XPath, Test::More, Test::Builder. perl v5.14.2 2012-06-05 Test::XML::Simple(3pm)

Check Out this Related Man Page

Template::Plugin::XML::XPath(3pm)			User Contributed Perl Documentation			 Template::Plugin::XML::XPath(3pm)

NAME
Template::Plugin::XML::XPath - Plugin interface to XML::XPath SYNOPSIS
# load plugin and specify XML file to parse [% USE xpath = XML.XPath(xmlfile) %] [% USE xpath = XML.XPath(file => xmlfile) %] [% USE xpath = XML.XPath(filename => xmlfile) %] # load plugin and specify XML text to parse [% USE xpath = XML.XPath(xmltext) %] [% USE xpath = XML.XPath(xml => xmltext) %] [% USE xpath = XML.XPath(text => xmltext) %] # then call any XPath methods (see XML::XPath docs) [% FOREACH page = xpath.findnodes('/html/body/page') %] [% page.getAttribute('title') %] [% END %] # define VIEW to present node(s) [% VIEW repview notfound='xmlstring' %] # handler block for a <report>...</report> element [% BLOCK report %] [% item.content(view) %] [% END %] # handler block for a <section title="...">...</section> element [% BLOCK section %] <h1>[% item.getAttribute('title') | html %]</h1> [% item.content(view) %] [% END %] # default template block passes tags through and renders # out the children recursivly [% BLOCK xmlstring; item.starttag; item.content(view); item.endtag; END %] # block to generate simple text [% BLOCK text; item | html; END %] [% END %] # now present node (and children) via view [% repview.print(page) %] # or print node content via view [% page.content(repview) %] DESCRIPTION
This is a Template Toolkit plugin interfacing to the XML::XPath module. All methods implemented by the XML::XPath modules are available. In addition, the XML::XPath::Node::Element module implements present($view) and content($view) methods method for seamless integration with Template Toolkit VIEWs. The XML::XPath::Node::Text module is also adorned with a present($view) method which presents itself via the view using the 'text' template. To aid the reconstruction of XML, methods starttag and endtag are added to XML::XPath::Node::Element which return the start and end tag for that element. This means that you can easily do: [% item.starttag %][% item.content(view) %][% item.endtag %] To render out the start tag, followed by the content rendered in the view "view", followed by the end tag. AUTHORS
This plugin module was written by Andy Wardley. The XML::XPath module is by Matt Sergeant. COPYRIGHT
Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, XML::XPath, XML::Parser perl v5.8.8 2008-03-01 Template::Plugin::XML::XPath(3pm)
Man Page