RevealTheme logo

XML转JSON工具

将XML文档转换为JSON。属性会转换为带@前缀的键;重复的标签会转换为数组。

如何使用本工具

  1. 1

    Paste or type your XML into the input box.

  2. 2

    Read the converted JSON in the output panel below, which updates as you type.

  3. 3

    If the XML is malformed, fix the error shown in red and the output will reappear.

  4. 4

    Select the JSON from the output panel to copy it into your project.

什么是XML转JSON工具?

从XML转换到JSON在某些方面会有信息损失:XML支持命名空间、处理指令和CDATA节,而这些在JSON中没有直接的对应物。本转换工具能处理90%的情况:嵌套元素、属性(带@前缀)和文本内容(#text)。对于复杂的XML,可能需要使用专门的库。

常见使用场景

  • Inspect a SOAP or legacy XML API response as JSON before wiring it into a JavaScript front end.

  • Convert an RSS or Atom feed snippet into JSON to prototype a parser quickly.

  • Turn a config file or build manifest written in XML into JSON to eyeball its structure.

  • Pull values out of an XML sitemap or data export when a JSON shape is easier to traverse.

  • Teach or learn how attributes, repeated tags, and text nodes map between the two formats.

  • Sanity-check that a small XML payload is well-formed, since malformed input shows a parser error.

常见问题

@前缀是什么意思?
属性以@属性名的形式存储,以便与同名的子元素区分开来。

相关工具