我希望您能帮助我使用 XSLT 将一些 XML 转换为新的 XML。我有选择多个 XML 并对它们应用 XSLT 的代码。
我的问题是 XSLT,我想将这些 shop1.xml shop2xml .. 转换为 allshops.xml。对于知道如何使用 XSLT 的人来说,这是一项简单的任务,因为只有 2-3 处更改。
您可以在下面找到更好理解的结构。非常感谢。
商店1.xml
<shop>
<products>
<product id="189">
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="61"></category>
</product>
</products>
</shop>
商店2.xml
<shop>
<products>
<product id="182">
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="62"></category>
</product>
</products>
</shop>
商店3.xml//这个直接有产品,因为 root 和 id 可能已经存在
<products>
<product>
<id>123</id>
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="62"></category>
</product>
</products>
路径.xml从 php 代码中使用它来获取多个 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<files>
<file>shop1.xml</file>
<file>shop2.xml</file>
<file>shop3.xml</file>
</files>
所有商店.xml
<products> //removed the store,shop and products stays as root
<product>
<id>the product's attribute id</id> //new element, with value the product id=""
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category></category> //removed the attribute id
<shopid></shopid> //new element, will be blank for now
</product>
<product>
</product>
.
.
.
</products>