What do I have to do to have e.g. findnodes() work again when I am parsing XML that has a namespace involved..?!?
If I run this code it works fine (returns 2 fields):
However, if I change the root element to
it won't run anymore.
I am clearly missing something about namespaces here, but I am quit at loss just what it is..?!?
If I run this code it works fine (returns 2 fields):
Code:
#!/usr/bin/perl
use strict;
use XML::LibXML;
my $sTestXml = <<TEST;
<?xml version="1.0" encoding="UTF-8"?>
<someRoot>
<someField/>
<someField>
<someValue nr="001">Bla bla</someValue>
<someValue nr="002">Blo blo</someValue>
</someField>
</someRoot>
TEST
my $oParser = XML::LibXML->new();
my $oTree = $oParser->parse_string($sTestXml);
my @aEntities = $oTree->documentElement->findnodes('someField');
print "Amount of fields: " . scalar(@aEntities) . "\n";
However, if I change the root element to
Code:
<someRoot xmlns="[URL unfurl="true"]http://www.bla.com/bla.xsd"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xsi:schemaLocation="[URL unfurl="true"]http://www.bla.com/bla.xsd">[/URL]
I am clearly missing something about namespaces here, but I am quit at loss just what it is..?!?