K
kj
Suppose I have some XML document that contains tags of the form
<... xmlns:foo="http://www.bar.org/foo">
<... xmlns:foo="baz">
<... xmlns:frobozz="http://www.bar.org/foo">
What's the XPath expression to select the namespace nodes with
prefix "foo"? And what's the XPath expression to select the
namespace nodes with value "http://www.bar.org/foo"?
I am using the Perl module XML::XPath. With it, I know how to
select namespace nodes with value "baz" (using
$xpath_obj->find('//namespace::baz')), but I get an error if I try
to select namespace nodes with value "http://www.bar.org/foo" using
$xpath_obj->find('//namespace::http://www.bar.org/foo'). I can
see why the latter would be problematic, since at least the slashes
in the namespace's value would collide with XPath syntax, but I
don't know how to escape them. (Actually, the parser seems to
choke on the colon after http before it gets to do so on the
slashes.)
With a full implementation of the XML::XPath standard, I suppose
I could try something like
$xpath_obj->find('namespace-uri(//namespace::*)="http://www.bar.org/foo"')),
but when I do this I get the error "namespace-uri: Function not
supported".
I have no clue how to use XML::XPath to select namespace nodes with
prefix "foo".
Thanks!
kj
P.S. Is there a "standard" forum for XPath-related queries like
this one?
<... xmlns:foo="http://www.bar.org/foo">
<... xmlns:foo="baz">
<... xmlns:frobozz="http://www.bar.org/foo">
What's the XPath expression to select the namespace nodes with
prefix "foo"? And what's the XPath expression to select the
namespace nodes with value "http://www.bar.org/foo"?
I am using the Perl module XML::XPath. With it, I know how to
select namespace nodes with value "baz" (using
$xpath_obj->find('//namespace::baz')), but I get an error if I try
to select namespace nodes with value "http://www.bar.org/foo" using
$xpath_obj->find('//namespace::http://www.bar.org/foo'). I can
see why the latter would be problematic, since at least the slashes
in the namespace's value would collide with XPath syntax, but I
don't know how to escape them. (Actually, the parser seems to
choke on the colon after http before it gets to do so on the
slashes.)
With a full implementation of the XML::XPath standard, I suppose
I could try something like
$xpath_obj->find('namespace-uri(//namespace::*)="http://www.bar.org/foo"')),
but when I do this I get the error "namespace-uri: Function not
supported".
I have no clue how to use XML::XPath to select namespace nodes with
prefix "foo".
Thanks!
kj
P.S. Is there a "standard" forum for XPath-related queries like
this one?