in reply to Filtering large XML files

To "extract" a node in XML::LibXML::Reader, use copyCurrentNode:
if ('text' eq $r->name and XML_READER_ELEMENT == $r->nodeType) { print $r->copyCurrentNode(1); }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Filtering large XML files
by PT (Novice) on Feb 23, 2015 at 11:21 UTC

    Thanks, this might work. Do you have any idea how to go about the <doc> node? I cannot simply use copyCurrentNode on that one. When I do this:

    if ('doc' eq $r->name and XML_READER_ELEMENT == $r->nodeType) { print $r->copyCurrentNode(0)->toString; }

    I get:

    <doc attr1=".." attr2=".."/>

    (an empty, self-closed <doc/>). Is there a clean way to correctly output it as just an opening XML_READER_ELEMENT?