我有两个XML文件 一个拥有产品,第二个具有颜色名称 使用delphi时,我将colors.xml加载到xml文档中,并且在解析了products.xml之后,我使用xpath查询从colors.xml文件中查找每个colorid的名称。
Products.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<products>
<p colorid="1">Product 1</p>
<p colorid="2">Product 2</p>
<p colorid="3">Product 3</p>
<p colorid="4">Product 4</p>
</products>
Colors.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<colors>
<c id="1">red</c>
<c id="2">yellow</c>
<c id="3">blue</c>
<c id="4">black</c>
<c id="5">green</c>
<c id="6">white</c>
</colors>
我想像这样从products.xml转换为final.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<products>
<p color="1" colorname="red">Product 1</p>
<p color="2" colorname="yellow">Product 2</p>
<p color="3" colorname="blue">Product 3</p>
<p color="4" colorname="black">Product 4</p>
</products>
使用delphi 7或更高版本
是否可以像使用xsd一样立即执行
还是我需要解析每个xml并创建新属性?