#!/usr/bin/perl use strict; use XML::LibXML 1.70; # Parse the document. XML::LibXML 1.70 introduced the load_xml method, # which is somewhat nicer than the pre-1.70 methods for parsing data. my $doc = XML::LibXML->load_xml(IO => \*DATA) or die; # In your original example, the building was "Building A", but there # was no node called "Building A" in the sample XML. my $bldg = 'Office'; my $floor = '1st Floor'; # I've changed your query so that it selects a element. # Previously it drilled down further to select the text inside # the node's