You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用WP ALL IMPORT将XML属性组导入WooCommerce商品描述?

使用WP All Import for WooCommerce导入XML规格到商品描述的方法

需求说明

需要将XML中<attribute_group name="Specs">下的所有属性导入为WooCommerce商品描述的HTML内容,属性的数量、种类、顺序不固定,仅以该属性组标签为识别标准。

源XML示例

<attribute_group name="Specs">
        <attribute name="color">White</attribute>
        <attribute name="series">Basic</attribute>
        <attribute name="power">40 W</attribute>
        <attribute name="voltage">220 V</attribute>
        <attribute name="SPL">90 dB</attribute>
        <attribute name="material">Wood</attribute>
        <attribute name="package">1 Pair</attribute>
</attribute_group>

期望生成的商品描述HTML

<p>Specs</p>
<p>color : White</p>
<p>series : Basic</p>
<p>power : 40 W</p>
<p>voltage : 220 V</p>
<p>SPL : 90 dB</p>
<p>material : Wood</p>
<p>package : 1 Pair</p>

实现步骤

  1. 进入WP All Import导入向导,选择目标XML数据源,完成基础导入配置后,进入自定义字段映射环节。
  2. 找到「商品描述(Product Description)」的映射输入框,点击输入框上方的**「循环」(Loop)**按钮,打开循环设置面板。
  3. 在循环的「XPath查询」输入框中,填入定位Specs属性组下所有attribute节点的表达式:
    //attribute_group[@name='Specs']/attribute
    
  4. 构建循环输出模板:
    • 先在循环模板外添加标题行:<p>Specs</p>
    • 在循环内容区域,填入每个属性的HTML格式:
      <p>{@name} : {.}</p>
      
      其中{@name}会读取当前attribute节点的name属性值,{.}会读取节点内的文本内容。
  5. (可选)如果需要清理文本前后的多余空格,可以使用WP All Import的内置函数优化模板:
    <p>{trim(@name)} : {trim(.)}</p>
    
  6. 完成设置后,点击「预览」确认生成的商品描述格式符合预期,无误后执行正式导入。

注意事项

  • WP All Import会自动遍历所有匹配的attribute节点,不管数量多少、顺序如何,都会按XML中的顺序生成对应内容,适配不同商品的属性差异。
  • 如果XML中存在多个attribute_group标签,该XPath表达式只会定位到name="Specs"的组,不会混淆其他属性组。

内容的提问来源于stack exchange,提问作者fou fou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 01:57:47