I see in the XML::Twig documentation the functions parse($text)
for parsing scalars contain xml text, and parsefile($fileName)
for reading in and parsing xml files. I would like to parse an input stream (a file handle or maybe STDIN). Still wading through documentation and haven't found anything. How should I do this?
Asked
Active
Viewed 528 times
4

Nate Glenn
- 6,455
- 8
- 52
- 95
-
Don't have any experience with any of them from CPAN, but from your description it sounds like you want a SAX parser. – Josh Y. Jan 20 '12 at 20:24
-
XML::Twig does SAX and DOM. I'm really just doing the filehandle thing to cover all of my bases in the future. – Nate Glenn Jan 20 '12 at 20:29
-
XML::Twig is not a SAX parser, but combination stream/tree (i.e. "twig", get it?) oriented. – runrig Jan 20 '12 at 21:59
1 Answers
8
XML::Twig
is a subclass of XML::Parser
, so you should be able to pass parse()
an open IO::Handle
.
-
1That's actually in the docs of XML::Twig, but I will make it more explicit that parse can be passed a filehandle. – mirod Jan 21 '12 at 06:38