#!/usr/bin/perl use strict; use warnings; use Test; BEGIN { plan tests => 4 } use XML::XPath; ok(1); my $xp = XML::XPath->new(ioref => *DATA); my @nodes; @nodes = $xp->findnodes('/order'); ok @nodes == 1, 1, q[the root element must be an order]; @nodes = $xp->findnodes('/order/customer'); ok @nodes == 1,1, q[an order must contain a customer element]; @nodes = $xp->findnodes('/order/customer/name'); ok @nodes == 1,1, q[an order must contain a customer element with name +]; __DATA__ <?xml version="1.0" standalone="yes"?> <order> <customer> <name>Coyote, Ltd.</name> <shipping_info> <address>1313 Desert Road</address> <city>Nowheresville</city> <state>AZ</state> <zip>90210</zip> </shipping_info> </customer>
In reply to Re: Need a way to figure which xml nodes are valid
by Khen1950fx
in thread Need a way to figure which xml nodes are valid
by dave_yankee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |