【发布时间】:2022-11-04 01:11:50
【问题描述】:
当我使用 XML::DOM 解析 XML 时,属性内的实体被移到了标签之外。
use XML::DOM;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile("demo.xml");
print $doc->toString;
示例演示 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE candy SYSTEM "demo.dtd">
<candy>
<product id="1">Mints</product>
<product id="xx*yy">Chocolate</product>
<product id="3">Circus Peanuts</product>
</candy>
但在输出中,第二个产品属性 id 中的“*”实体被移到了标签之外。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE candy SYSTEM "demo.dtd">
<candy>
<product id="1">Mints</product>
*<product id="xxyy">Chocolate</product>
<product id="3">Circus Peanuts</product>
</candy>
我需要 XML 原样。
【问题讨论】: