Commits

ma...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 22f04fb

Added PI and comment support

  • Participants
  • Parent commits 0c03a13

Comments (0)

Files changed (1)

File lib/XML/LibXML/SAX/Parser.pm

     my ($node) = @_;
     
     $self->start_document({});
-    
+    $self->xml_decl({Version => $node->getVersion, Encoding => $node->getEncoding});
     $self->process_node($node);
     
     $self->end_document({});
         }
     }
     elsif ($node_type == XML_DOCUMENT_NODE) {
-        # just get root element. Ignore other cruft.
         foreach my $kid ($node->getChildnodes) {
-            if ($kid->getType() == XML_ELEMENT_NODE) {
-                $self->process_element($kid);
-                last;
-            }
+            $self->process_node($kid);
         }
     }
+    elsif ($node_type == XML_PI_NODE) {
+        $self->processing_instruction( { Target =>  $node->getName, Data => $node->getData } );
+    }
+    elsif ($node_type == XML_COMMENT_NODE) {
+        $self->comment( { Data => $node->getData } );
+    }
     else {
         warn("unsupported node type: $node_type");
     }