, . TEI XML, ,
&some_exotic_char;
DTD. , , XML.
BeautifulSoup , XML :
with open('outfile.xml','w') as outfile:
outfile.write(soup.prettify())
" ", utf8-, , . , XML, prettify ( ).
, , , , Perl XML :: LibXML.
$parser->expand_entities(0);
entities will not be expanded. And writing the XML back to the file will keep the original layout intact.
use XML::LibXML;
my $parser = new XML::LibXML;
$parser->validation(0);
$parser->load_ext_dtd(1);
$parser->expand_entities(0);
my $doc = $parser->parse_file('infile.xml');
...
open my $out, '>', 'outfile.xml';
binmode $out;
print $out $doc->toString();
close $out;
Perl XML :: LibXML saved my day.
source
share