vibha has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have a problem when I try using the parse_string of XML::LibXML::Dtd
my code:

my $doc = XML::LibXML->new->parse_file ($file);
my $dtd = $doc->internalSubset;
my $dtd_str = $dtd->toString(1,1);
#Some code here to modify the dtd path, which I donot have yet -but even without this the below does not work
$dtd = XML::LibXML::Dtd->parse_string($dtd_str);
$doc->setInternalSubset($dtd);

The parse_string line thows an error
Entity: line 1: parser error : Content error in the external subset
<!DOCTYPE pageItem SYSTEM "http://webdev.kodak.com/global/mul/business/docimagin
^
Entity: line 1: parser error : Content error in the external subset
<!DOCTYPE pageItem SYSTEM "http://webdev.kodak.com/global/mul/business/docimagin
^

Please help! Is the $dtd_str not in the right format? I have tried to find help about the format of input to parse_string but failed.
Basically I need to change the DTD paths in some xml files. I figured if the above works I can do that easily.
But :(
Thanks!

  • Comment on XML::LibXML update DTD/DOCTYPE in xml file

Replies are listed 'Best First'.
Re: XML::LibXML update DTD/DOCTYPE in xml file
by ssk (Initiate) on Dec 23, 2005 at 13:13 UTC

    i think the doctype path should be PUBLIC instead of SYSTEM

    i.e.

    <!DOCTYPE pageItem SYSTEM "http://webdev.kodak.com/global/mul/business/docimagin ....

    should be

    <!DOCTYPE pageItem PUBLIC "http://webdev.kodak.com/global/mul/business/docimagin ....