Howdy Sandorado, welcome to the Monastery!

This is all I have, because I don't know how to go further. (get always the error message: Can_t locate object or reference "getAttribute" via package XML::LibXML::Nodelist)

That's because XML::LibXML::Nodelist does not have that method. That's natural, because objects of this type represent lists of nodes, not individual nodes; what you'd want to do is call ->foreach() on the Nodelist object, and - for each individual node - call ->attributes() and see if the attributes you're looking for are present.

That said, you don't have to do it that way. If you're interested in selecting specific nodes of an XML document, use an XPath expression. XML::LibXML has a ->findnodes method for that that you can call on any node (e.g. the document root); alternatively, use a module like XML::XPath.

The specific XPath expression you'll want depends on what nodes you're looking for, of course, but you might use something like //metadata[@attribute1 and @Attribute2] to select all metadata elements that have both attribute1 and Attribute2 elements (regardless of value).

I recommend taking a look at the XPath spec for more; section 2.5 has a number of useful examples that are much easier to understand than the formal grammar.


In reply to Re: Child contains attribute by AppleFritter
in thread Child contains attribute by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.