我希望你的帮助可以使用XSLT将一些XML转换为新的XML.我有选择多个XML并在其上应用XSLT的代码.
我的问题是XSLT,我想将那些shop1.xml shop2xml ..转换为allshops.xml.对于知道如何使用XSLT的人来说,这是一项简单的任务,因为只有2-3个更改.
您可以在下面找到更好理解的结构.非常感谢你.
shop1.xml
<shop>
<products>
<product id="189">
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="61"></category>
</product>
</products>
</shop>
Run Code Online (Sandbox Code Playgroud)
shop2.xml
<shop>
<products>
<product id="182">
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="62"></category>
</product>
</products>
</shop>
Run Code Online (Sandbox Code Playgroud)
shop3.xml //这个产品直接以root身份生产,而且id可能已经存在
<products>
<product>
<id>123</id>
<title></title>
<description></description>
<price></price>
<image></image>
<url></url>
<category id="62"></category>
</product>
</products>
Run Code Online (Sandbox Code Playgroud)
paths.xml它是从PHP代码中使用来获取多个xml文件
<?xml version="1.0" encoding="utf-8"?>
<files>
<file>shop1.xml</file>
<file>shop2.xml</file>
<file>shop3.xml</file>
</files>
Run Code Online (Sandbox Code Playgroud)
allshops.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 …Run Code Online (Sandbox Code Playgroud)