[Expat-discuss] junk after document element at line 2053
Michel Rodriguez
mirod at xmltwig.com
Tue May 18 11:16:35 EDT 2004
Hi,
Coming late in the discussion...
Is there any chance you could use the Stream_Delimiter option when you
create the XML::Parser?
>From the docs:
· Stream_Delimiter
This is an Expat option. It takes a string value. When this
string is found alone on a line while parsing from a stream,
then the parse is ended as if it saw an end of file. The
intended use is with a stream of xml documents in a MIME multi-
part format. The string should not contain a trailing newline.
This means you would have to insert the delimiter in the file, but this
could be handled by piping the initial file through a simple Perl script
that would substitute the prolog by the delimiter + prolog, as in
(untested):
my $MARK= "<>";
open( XML_IN, "perl -p -e's{(<?xml )}{$MARK\n\$1}' | "
XML::Parser->new( Stream_Delimiter => $MARK)->parse( \*XML_IN);
Of course this has all the usual disadvantages of non-XML solutions: you
assume that both $MARK and '<?xml ' will not be found in the XML
(this is of course dangerous mostly if you are dealing with XML that uses
CDATA section to embed XML, which hapeens in articles about XML for
example).
Does this help?
--
Michel Rodriguez
Perl & XML
http://www.xmltwig.com
More information about the Expat-discuss
mailing list