This extracts all the childnodes into an array. I've printed them out with numbers and delimiter so you can see them individually. I suggest you loop through them extracting all or any that you want.

#!perl use strict; use XML::LibXML; my $dom = XML::LibXML->load_xml( IO => *DATA ); my $study_str = 'Purpose and rationale|Study purpose|Study rationale'; for my $search ('//header') { my $nodeset = $dom->find($search); foreach my $node ($nodeset->get_nodelist){ if ($node =~ m/$study_str/i){ my @childnodes = $node->nonBlankChildNodes(); my $n=1; for (@childnodes){ print '#'.$n++.'# '.$_->toString."##\n\n"; } } } } __DATA__ <root> <part><sect> <header> 1. Purpose and rationale doc 1 <p>purpose 1</p> <p>Purpose 2</p> <p>purpose 3</p> <ul> <li>purpose list 1</li> <li>list2</li> </ul> <p>2. Some other heading</p> <p>content 1</p> <p>content 2</p> </header> </sect></part> </root>
poj

In reply to Re: Having trouble with siblings by poj
in thread Having trouble with siblings by madbee

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.