fast-xml-customer
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "fast-xml-customer" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-63c96d0dae0b9689ceccb861f7895a4f14dca2609e1b669a36d6f04d6b92c2e7. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/gnz20268469 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Performs client data conversion between XML and JSON in the browser using fast-xml-parser to facilitate import and export. Suitable for scenarios that require front-end processing of customer data and conversion between XML and JSON with fast-xml-parser.
Introduction source: third_party · user_f1b049da · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: fast-xml-customer
slug: gnz20268469
displayName: XML导入导出
version: 1.0.0
summary: 用 fast-xml-parser 本地互转客户 XML 与 JSON。
license: MIT
description: 用 fast-xml-parser 在浏览器内把客户资料在 XML 与 JSON 之间互转,便于导入导出。当用户需要 XML 导入导出、fast-xml-parser、客户 XML/JSON 互转时使用。XML 导入导出(fast-xml-parser)
灵感:能力工具箱 fast-xml(pkg: fast-xml-parser)。
在浏览器本地把客户列表/单条客户在 XML 与 JSON 之间互转,用于导入旧系统导出包或导出给对方,不请求后端解析。
何时使用
- 客户 XML 文件导入 CRM 演示数据
- 把 JSON 客户导出为 XML 下载
- 需要可控的属性/数组解析选项
硬约束
- 依赖
fast-xml-parser(XMLParser+XMLBuilder)。 - 解析失败返回中文原因;禁止把异常堆栈直接甩给用户。
- 导入后做基础字段归一(如
name/mobile),缺关键字段要提示。 - 不执行 XML 内外部实体攻击面:禁用或避免解析不可信 DTD/实体(按库选项关闭危险特性)。
- 纯本地;大文件提示体积,避免卡死主线程(可抽 Worker,可选)。
推荐实现要点
import { XMLParser, XMLBuilder } from 'fast-xml-parser'
const parser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: '@_',
allowBooleanAttributes: true,
})
const builder = new XMLBuilder({
ignoreAttributes: false,
attributeNamePrefix: '@_',
format: true,
})
export type CustomerLite = { name: string; mobile?: string; company?: string }
export function xmlToCustomers(xml: string): { ok: true; list: CustomerLite[] } | { ok: false; reason: string } {
try {
const doc = parser.parse(xml)
const raw = doc?.customers?.customer ?? doc?.customer ?? []
const arr = Array.isArray(raw) ? raw : raw ? [raw] : []
const list: CustomerLite[] = arr.map((c: any) => ({
name: String(c.name ?? c['@_name'] ?? '').trim(),
mobile: c.mobile ? String(c.mobile) : undefined,
company: c.company ? String(c.company) : undefined,
})).filter((c) => c.name)
if (!list.length) return { ok: false, reason: '未解析到有效客户节点' }
return { ok: true, list }
} catch {
return { ok: false, reason: 'XML 格式无法解析' }
}
}
export function customersToXml(list: CustomerLite[]): string {
return builder.build({ customers: { customer: list } })
}
Agent 步骤
- 安装
fast-xml-parser,封装xmlToCustomers/customersToXml。 - 提供文件选择导入 +「导出 XML」下载(可配合 file-saver)。
- 自测:样例 XML 往返字段不丢;坏 XML 有中文错误。
附加
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决客户资料 XML 与 JSON 互转的实际导入导出需求
- 适用于 CRM 数据迁移和系统对接场景
Highlights
- 触发场景描述清晰,覆盖 XML 导入导出、格式转换等关键用例
Areas to improve
-
缺少完整端到端用户交互示例 Reported severity: Minor
文档提供了代码实现要点,但缺少从用户选择文件到完成导入/导出的完整操作流程示例
Recommendation: 补充一个完整的用户操作示例,包括文件选择、解析、错误处理、下载导出的全流程说明
Highlights
- 文档结构清晰,包含硬约束和推荐实现要点
- 提供了可复用的 TypeScript 代码片段
Areas to improve
-
文件操作实现细节未明确 Reported severity: Minor
提及文件选择导入和导出下载,但未展示具体实现代码或错误处理
Recommendation: 补充文件读取、下载导出的具体实现,并增加文件大小校验和用户提示
Highlights
- 使用 fast-xml-parser 并配置安全选项,避免 XML 外部实体攻击
- 解析失败返回中文错误信息,提升用户体验
- 包含基础字段归一和关键字段校验逻辑
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.