First, there's an error in the XML.
<MyImportantNode> xsi:type="foo" GeneralID="Random1" >
should be
<MyImportantNode xsi:type="foo" GeneralID="Random1" >
(Same goes for the other two.)
4 of the 5 paths you tried in the loop start with "/". That means they start looking at the root of the tree. That instantly makes them wrong since you obviously want something that's in or below $nodeybits.
Another major problem is that you look for the nodes in the wrong namespace throughout the body of the loop. You don't even use the xpc!
<?xml version="1.0" encoding="UTF-8"?>
<RootTag SchemaVersion="1.1" xmlns="http://www.wow.com/BlahML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocati
+on="http://www.wow.com/BlahML BlahML1_1.xsd">
<MyTagA Tag="XXX">Some Text A</MyTagA>
<MyTagB Tag="XXX">Some Text A</MyTagB>
<MiddleTag xsi:type="foo" magicvalue="wow">
<MyImportantNode xsi:type="foo" GeneralID="Random1" >
<CannotGetTagA>YYYYYYYYYYY</CannotGetTagA>
<CannotGetTagB>ZZZZZZZZZZZ</CannotGetTagB>
</MyImportantNode>
<MyImportantNode xsi:type="foo" GeneralID="Random2" >
<CannotGetTagA>YYYYYYYYYY22</CannotGetTagA>
<CannotGetTagB>ZZZZZZZZZZ22</CannotGetTagB>
</MyImportantNode>
<MyImportantNode xsi:type="foo" GeneralID="Random3" >
<CannotGetTagA>YYYYYYYYY333</CannotGetTagA>
<CannotGetTagB>ZZZZZZZZZ333</CannotGetTagB>
</MyImportantNode>
</MiddleTag>
</RootTag>
use strict;
use warnings;
use feature qw( say );
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file('test.xml');
my $xpc = XML::LibXML::XPathContext->new($doc);
$xpc->registerNs(theNS => 'http://www.wow.com/BlahML');
for my $important_node (
$xpc->findnodes('//theNS:MiddleTag/theNS:MyImportantNode')
) {
say $important_node->getAttribute('GeneralID');
for my $cannot_get_a_node (
$xpc->findnodes('theNS:CannotGetTagA', $important_node)
) {
say $cannot_get_a_node->textContent();
}
}