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.

常見問題

@ 前綴是什麼意思?
屬性以 @屬性名 的形式儲存,以便與同名的子元素區分開來。

相關工具