title: How can I access attributes and elements from XML::LibXML in Perl?
body: <p>I am having trouble understanding / using name spaces with <a href="http://search.cpan.org/dist/XML-LibXML" rel="noreferrer">XML::LibXML</a> package in Perl.  I can access an element successfully but not an attribute.  I have the following code which accesses an XML file (<a href="http://pastebin.com/f3fb9d1d0" rel="noreferrer">http://pastebin.com/f3fb9d1d0</a>).</p>
  
  <pre><code>my $tree = $parser-&gt;parse_file($file); # parses the file contents into the new libXML object.
  my $xpc = XML::LibXML::XPathContext-&gt;new($tree); 
  $xpc-&gt;registerNs(microplateML =&gt; 'http://moleculardevices.com/microplateML');   
  </code></pre>
  
  <p>I then try and access an element called common-name and an attribute called name.</p>
  
  <pre><code>foreach my $camelid ($xpc-&gt;findnodes('//microplateML:species')) {
    my $latin_name = $camelid-&gt;findvalue('@name');   
    my $common_name = $camelid-&gt;findvalue('common-name');  
    print "$latin_name, $common_name" ;
  }
  </code></pre>
  
  <p>But only the latin-name (<code>@name</code>) is printing out, the common-name is not.  What am I doing wrong and how can I get the common-name to print out as well?</p>
  
  <p>What does the @name do in this case?  I presume it is an array, and that attributes should be put into an array as there can be more than one, but elements (like common-name) should not be because there should just be one?</p>
  
  <p>I've been following the examples here: <a href="http://www.xml.com/pub/a/2001/11/14/xml-libxml.html" rel="noreferrer">http://www.xml.com/pub/a/2001/11/14/xml-libxml.html</a>
  and here: <a href="http://perl-xml.sourceforge.net/faq/#namespaces_xpath" rel="noreferrer">http://perl-xml.sourceforge.net/faq/#namespaces_xpath</a>, and trying to get their example camel script working with my namespace, hence the weird namespace.  </p>