{"id":1315,"date":"2026-01-11T16:38:02","date_gmt":"2026-01-11T08:38:02","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=1315"},"modified":"2026-01-11T16:38:02","modified_gmt":"2026-01-11T08:38:02","slug":"xml%e5%9c%a8%e7%ba%bf%e6%a0%bc%e5%bc%8f%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2026\/01\/11\/xml%e5%9c%a8%e7%ba%bf%e6%a0%bc%e5%bc%8f%e5%8c%96\/","title":{"rendered":"xml\u5728\u7ebf\u683c\u5f0f\u5316"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4e2a<strong>\u53ef\u76f4\u63a5\u4e0a\u7ebf\u4f7f\u7528\u7684\u300cXML \u5728\u7ebf\u683c\u5f0f\u5316\u5de5\u5177\u300d<\/strong>\uff0c\u652f\u6301 <strong>\u683c\u5f0f\u5316 \/ \u538b\u7f29 \/ \u6821\u9a8c\u9519\u8bef<\/strong>\uff0c\u9002\u5408\u653e\u5728 <strong>\u5de5\u5177\u7ad9 \/ \u535a\u5ba2 \/ WordPress \u524d\u53f0\u9875\u9762<\/strong>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddfe XML \u5728\u7ebf\u683c\u5f0f\u5316<\/h1>\n\n\n\n<p><strong>XML Pretty \/ Minify \/ \u6821\u9a8c\u5de5\u5177<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u529f\u80fd\u8bf4\u660e<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2714 XML <strong>\u4e00\u952e\u7f8e\u5316\uff08\u7f29\u8fdb\u3001\u6362\u884c\uff09<\/strong><\/li>\n\n\n\n<li>\u2714 XML <strong>\u538b\u7f29\u6210\u4e00\u884c<\/strong><\/li>\n\n\n\n<li>\u2714 XML <strong>\u8bed\u6cd5\u6821\u9a8c\uff08\u9519\u8bef\u63d0\u793a\uff09<\/strong><\/li>\n\n\n\n<li>\u2714 \u7eaf\u524d\u7aef\u5b9e\u73b0\uff0c<strong>\u6570\u636e\u4e0d\u4e0a\u4f20\u670d\u52a1\u5668<\/strong><\/li>\n\n\n\n<li>\u2714 \u652f\u6301\u5927\u6587\u672c\u3001\u590d\u5236\u5373\u7528<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf10 \u4f7f\u7528\u573a\u666f<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u63a5\u53e3\u8fd4\u56de XML \u8c03\u8bd5<\/li>\n\n\n\n<li>WebService \/ SOAP \u6392\u9519<\/li>\n\n\n\n<li>\u914d\u7f6e\u6587\u4ef6\u68c0\u67e5<\/li>\n\n\n\n<li>\u5b66\u4e60 XML \u7ed3\u6784<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udca1 \u5b8c\u6574\u53ef\u7528\u4ee3\u7801\uff08HTML + CSS + JS\uff09<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u4fdd\u5b58\u4e3a <code>xml-formatter.html<\/code> \u5373\u53ef\u4f7f\u7528<\/p>\n<\/blockquote>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;!DOCTYPE html&gt;\n&amp;lt;html lang=&quot;zh-Hant&quot;&gt;\n&amp;lt;head&gt;\n&amp;lt;meta charset=&quot;UTF-8&quot;&gt;\n&amp;lt;title&gt;XML\u5728\u7dda\u683c\u5f0f\u5316 | XML Pretty \/ \u6821\u9a57\u5de5\u5177&amp;lt;\/title&gt;\n&amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n\n&amp;lt;style&gt;\nbody {\n  background: #0f172a;\n  color: #e5e7eb;\n  font-family: system-ui, -apple-system;\n  padding: 20px;\n}\n\n.container {\n  max-width: 900px;\n  margin: auto;\n}\n\nh1 {\n  text-align: center;\n  margin-bottom: 20px;\n}\n\ntextarea {\n  width: 100%;\n  height: 260px;\n  padding: 15px;\n  border-radius: 12px;\n  border: none;\n  font-size: 14px;\n  background: #020617;\n  color: #38bdf8;\n  font-family: Consolas, monospace;\n}\n\n.buttons {\n  display: flex;\n  gap: 12px;\n  margin: 15px 0;\n}\n\nbutton {\n  flex: 1;\n  padding: 12px;\n  border: none;\n  border-radius: 10px;\n  font-size: 15px;\n  cursor: pointer;\n  background: linear-gradient(135deg,#6366f1,#3b82f6);\n  color: #fff;\n}\n\n.result {\n  margin-top: 10px;\n  font-size: 14px;\n  color: #22c55e;\n}\n.error {\n  color: #ef4444;\n}\n&amp;lt;\/style&gt;\n&amp;lt;\/head&gt;\n\n&amp;lt;body&gt;\n&amp;lt;div class=&quot;container&quot;&gt;\n  &amp;lt;h1&gt;\ud83e\uddfe XML \u5728\u7dda\u683c\u5f0f\u5316\u5de5\u5177&amp;lt;\/h1&gt;\n\n  &amp;lt;textarea id=&quot;xmlInput&quot; placeholder=&quot;\u8acb\u8cbc\u4e0a XML \u5167\u5bb9...&quot;&gt;&amp;lt;\/textarea&gt;\n\n  &amp;lt;div class=&quot;buttons&quot;&gt;\n    &amp;lt;button onclick=&quot;formatXML()&quot;&gt;\u683c\u5f0f\u5316&amp;lt;\/button&gt;\n    &amp;lt;button onclick=&quot;minifyXML()&quot;&gt;\u58d3\u7e2e&amp;lt;\/button&gt;\n    &amp;lt;button onclick=&quot;validateXML()&quot;&gt;\u6821\u9a57&amp;lt;\/button&gt;\n  &amp;lt;\/div&gt;\n\n  &amp;lt;div id=&quot;msg&quot; class=&quot;result&quot;&gt;&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;script&gt;\nfunction parseXML(xml) {\n  const parser = new DOMParser();\n  const doc = parser.parseFromString(xml, &quot;application\/xml&quot;);\n  const err = doc.getElementsByTagName(&quot;parsererror&quot;);\n  if (err.length) throw new Error(err&#x5B;0].textContent);\n  return doc;\n}\n\nfunction formatXML() {\n  try {\n    const xml = document.getElementById(&quot;xmlInput&quot;).value;\n    const doc = parseXML(xml);\n    const serializer = new XMLSerializer();\n    let formatted = serializer.serializeToString(doc);\n\n    formatted = formatted.replace(\/&gt;&amp;lt;\/g, &quot;&gt;\\n&amp;lt;&quot;);\n    document.getElementById(&quot;xmlInput&quot;).value = formatted;\n    showMsg(&quot;\u2705 XML \u683c\u5f0f\u5316\u5b8c\u6210&quot;);\n  } catch (e) {\n    showError(e.message);\n  }\n}\n\nfunction minifyXML() {\n  try {\n    const xml = document.getElementById(&quot;xmlInput&quot;).value;\n    parseXML(xml);\n    const minified = xml.replace(\/\\s+\/g, &quot; &quot;).trim();\n    document.getElementById(&quot;xmlInput&quot;).value = minified;\n    showMsg(&quot;\u2705 XML \u5df2\u58d3\u7e2e&quot;);\n  } catch (e) {\n    showError(e.message);\n  }\n}\n\nfunction validateXML() {\n  try {\n    parseXML(document.getElementById(&quot;xmlInput&quot;).value);\n    showMsg(&quot;\u2705 XML \u8a9e\u6cd5\u6b63\u78ba&quot;);\n  } catch (e) {\n    showError(&quot;\u274c XML \u932f\u8aa4\uff1a&quot; + e.message);\n  }\n}\n\nfunction showMsg(msg) {\n  const el = document.getElementById(&quot;msg&quot;);\n  el.className = &quot;result&quot;;\n  el.innerText = msg;\n}\n\nfunction showError(msg) {\n  const el = document.getElementById(&quot;msg&quot;);\n  el.className = &quot;result error&quot;;\n  el.innerText = msg;\n}\n&amp;lt;\/script&gt;\n&amp;lt;\/body&gt;\n&amp;lt;\/html&gt;\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4e2a\u53ef\u76f4\u63a5\u4e0a\u7ebf\u4f7f\u7528\u7684\u300cXML \u5728\u7ebf\u683c\u5f0f\u5316\u5de5\u5177\u300d\uff0c\u652f\u6301 \u683c\u5f0f\u5316 \/ \u538b\u7f29 &#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2026\/01\/11\/xml%e5%9c%a8%e7%ba%bf%e6%a0%bc%e5%bc%8f%e5%8c%96\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1315","post","type-post","status-publish","format-standard","hentry","category-xml-xslt"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/1315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=1315"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/1315\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/1315\/revisions\/1316"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=1315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=1315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=1315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}