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

WP All Import/WordPress下获取节点名称及产品类型映射求助

WP All Import 处理嵌套product_type节点的脚本方案

获取节点名称

在WP All Import的字段映射中,使用自定义PHP脚本可直接获取<product_type>节点的名称:

$node_name = $xml->getName();
echo $node_name;

执行后会输出节点标签名product_type。

获取产品类型值

如果产品类型值存储在<product_type>下的<reference>节点中,用以下脚本提取:

$product_type = $xml->reference;
echo $product_type;

这段代码会输出<reference>标签内的对应值。

同时获取节点名称和产品类型值

若需要一次性输出两者,可使用拼接脚本:

$node_name = $xml->getName();
$product_type_val = $xml->reference;
echo "节点名称:{$node_name},产品类型:{$product_type_val}";

使用方法

在WP All Import的字段映射界面,选择「自定义代码/PHP函数」选项,将上述对应脚本粘贴到输入框中即可生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 13:54:54