{"id":131,"date":"2025-11-24T14:35:39","date_gmt":"2025-11-24T06:35:39","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=131"},"modified":"2025-11-24T14:35:39","modified_gmt":"2025-11-24T06:35:39","slug":"%e7%ae%80%e5%8d%95%e4%ba%86%e8%a7%a3xml%e4%b8%ad%e7%9a%84%e5%a4%84%e7%90%86%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/24\/%e7%ae%80%e5%8d%95%e4%ba%86%e8%a7%a3xml%e4%b8%ad%e7%9a%84%e5%a4%84%e7%90%86%e6%8c%87%e4%bb%a4\/","title":{"rendered":"\u7b80\u5355\u4e86\u89e3XML\u4e2d\u7684\u5904\u7406\u6307\u4ee4"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd<strong>\u7b80\u6d01\u660e\u4e86\u3001\u5feb\u901f\u5165\u95e8\u7684\u300aXML \u5904\u7406\u6307\u4ee4\uff08Processing Instruction, PI\uff09\u57fa\u7840\u6307\u5357\u300b<\/strong>\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u7406\u89e3\u5b83\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48\u5b58\u5728\u3001\u600e\u4e48\u5199\u3001\u600e\u4e48\u7528\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u4e00\u3001\u4ec0\u4e48\u662f XML \u5904\u7406\u6307\u4ee4\uff08Processing Instruction, PI\uff09\uff1f<\/h1>\n\n\n\n<p>\u5904\u7406\u6307\u4ee4\uff08PI\uff09\u662f XML \u4e2d\u4e00\u79cd<strong>\u4e13\u95e8\u7ed9\u5e94\u7528\u7a0b\u5e8f\u6216\u89e3\u6790\u5668\u4f20\u9012\u4fe1\u606f\u7684\u6307\u4ee4<\/strong>\u3002<\/p>\n\n\n\n<p>\u57fa\u672c\u683c\u5f0f\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?target data?&gt;\n\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>target<\/strong>\uff1a\u6307\u4ee4\u7684\u76ee\u6807\uff08\u7ed9\u8c01\u770b\u7684\uff09<\/li>\n\n\n\n<li><strong>data<\/strong>\uff1a\u4f20\u9012\u7ed9\u76ee\u6807\u7a0b\u5e8f\u7684\u4fe1\u606f<\/li>\n<\/ul>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PI <strong>\u4e0d\u662f<\/strong> XML \u5143\u7d20<\/li>\n\n\n\n<li>XML \u89e3\u6790\u5668\u4e0d\u4f1a\u4fee\u6539\u6587\u6863\u7ed3\u6784\uff0c\u53ea\u628a PI \u4ea4\u7ed9\u5bf9\u5e94\u7684\u5e94\u7528\u7a0b\u5e8f\u53bb\u89e3\u91ca<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u4e8c\u3001\u6700\u5e38\u89c1\u7684\u5904\u7406\u6307\u4ee4\u793a\u4f8b<\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 1. XML \u6587\u6863\u58f0\u660e\uff08\u867d\u7136\u4e0d\u662f\u4e25\u683c\u610f\u4e49\u4e0a\u7684 PI\uff0c\u4f46\u957f\u5f97\u4e00\u6837\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7279\u522b\u6ce8\u610f<\/strong>\uff1a<code>xml<\/code> \u662f\u4fdd\u7559 target\uff0c\u4e0d\u5c5e\u4e8e\u81ea\u5b9a\u4e49 PI\u3002<\/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\">\u2714 2. xml-stylesheet \u2014\u2014 \u6700\u5e38\u7528\u7684 PI<\/h2>\n\n\n\n<p>\u7528\u4e8e\u544a\u8bc9\u6d4f\u89c8\u5668\u5e94\u8be5\u7528\u54ea\u4e2a\u6837\u5f0f\u8868\uff08XSL\u3001CSS\uff09\u663e\u793a XML\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\u5c06 XML \u7ed1\u5b9a\u5230 XSLT \u6587\u4ef6\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?xml-stylesheet type=&quot;text\/xsl&quot; href=&quot;style.xsl&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<p>\u7ed1\u5b9a CSS\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?xml-stylesheet type=&quot;text\/css&quot; href=&quot;style.css&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<p>\u8fd9\u662f XML WEB \u5c55\u793a\u4e2d\u6700\u5e38\u7528\u7684\u5904\u7406\u6307\u4ee4\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 3. \u81ea\u5b9a\u4e49\u5904\u7406\u6307\u4ee4<\/h2>\n\n\n\n<p>\u4e00\u4e9b\u5e94\u7528\u7a0b\u5e8f\u4f1a\u4f7f\u7528\u5b9a\u5236 PI \u505a\u6807\u8bb0\u3001\u914d\u7f6e\u6216\u5904\u7406\u63a7\u5236\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?printer color=&quot;true&quot; copies=&quot;2&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<p>\u7531\u6253\u5370\u7cfb\u7edf\u89e3\u6790\u3002<\/p>\n\n\n\n<p>\u518d\u5982\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?php echo &#039;Hello&#039;; ?&gt;\n\n<\/pre><\/div>\n\n\n<p>\u8fd9\u662f PHP \u5728 HTML\/XML \u4e2d\u7684\u5178\u578b\u5e94\u7528\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u4e09\u3001\u5904\u7406\u6307\u4ee4\u7684\u7528\u9014<\/h1>\n\n\n\n<p>\u5904\u7406\u6307\u4ee4\u5e2e\u52a9 XML \u4e0e\u5916\u90e8\u5e94\u7528\u901a\u4fe1\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7528\u9014<\/th><th>\u793a\u4f8b<\/th><\/tr><\/thead><tbody><tr><td>\u6307\u5b9a\u6837\u5f0f\u8868<\/td><td>XSL\u3001CSS<\/td><\/tr><tr><td>\u6307\u5b9a\u5916\u90e8\u7cfb\u7edf\u884c\u4e3a<\/td><td>\u6253\u5370\u8bbe\u7f6e\u3001\u6e32\u67d3\u65b9\u6848<\/td><\/tr><tr><td>\u6587\u6863\u5904\u7406\u63d0\u793a<\/td><td>\u7f13\u5b58\u3001\u7f16\u8bd1\u5668\u63d0\u793a<\/td><\/tr><tr><td>\u5d4c\u5165\u811a\u672c\u8bed\u8a00\u6307\u4ee4<\/td><td>PHP\u3001ASP \u7b49<\/td><\/tr><tr><td>\u4e3a\u7279\u5b9a\u8f6f\u4ef6\u5de5\u5177\u4f20\u53c2<\/td><td>\u7f16\u8f91\u5668\u3001\u8f6c\u6362\u5668<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u56db\u3001\u5904\u7406\u6307\u4ee4\u7684\u89c4\u5219\uff08\u5fc5\u987b\u8bb0\u4f4f\uff01\uff09<\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 1. \u4e0d\u80fd\u4f7f\u7528\u76ee\u6807\u540d\u79f0 <code>xml<\/code><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?xml something?&gt;   \u274c \u9519\u8bef\n\n<\/pre><\/div>\n\n\n<p>\u56e0\u4e3a <code>xml<\/code> \u4fdd\u7559\u7ed9 XML \u58f0\u660e\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 2. \u4e0d\u80fd\u5305\u542b <code>?&gt;<\/code> \u5b57\u7b26<\/h2>\n\n\n\n<p>\u5982\u679c\u51fa\u73b0\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?test data ?&gt; more ?&gt;\n\n<\/pre><\/div>\n\n\n<p>\u89e3\u6790\u4f1a\u51fa\u9519\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 3. PI \u53ef\u4ee5\u51fa\u73b0\u5728\u6587\u6863\u51e0\u4e4e\u4efb\u4f55\u4f4d\u7f6e\uff08\u4f46\u4e0d\u80fd\u5728\u6807\u7b7e\u5185\u90e8\uff09<\/h2>\n\n\n\n<p>\u6b63\u786e\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?note created=&quot;2025-11-24&quot;?&gt;\n&amp;lt;root&gt;...&amp;lt;\/root&gt;\n\n<\/pre><\/div>\n\n\n<p>\u9519\u8bef\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;root &amp;lt;?note x=&quot;1&quot;?&gt; &gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 4. PI \u5bf9 XML \u7ed3\u6784\u65e0\u5f71\u54cd<\/h2>\n\n\n\n<p>\u5b83\u65e2\u4e0d\u662f\u8282\u70b9\uff0c\u4e5f\u4e0d\u662f\u6807\u7b7e\uff0c\u56e0\u6b64\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u5f62\u6210\u7236\u5b50\u5173\u7cfb<\/li>\n\n\n\n<li>\u4e0d\u53c2\u4e0e\u6587\u6863\u6811<\/li>\n\n\n\n<li>DOM \u4e2d\u4f1a\u88ab\u89e3\u6790\u4e3a <code>ProcessingInstruction<\/code> \u5bf9\u8c61<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u4e94\u3001DOM \u4e2d\u5982\u4f55\u8bfb\u53d6\u5904\u7406\u6307\u4ee4\uff1f<\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 Java DOM<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nNodeList list = doc.getChildNodes();\nfor (int i = 0; i &amp;lt; list.getLength(); i++) {\n    Node node = list.item(i);\n    if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {\n        System.out.println(node.getNodeName() + &quot; : &quot; + node.getNodeValue());\n    }\n}\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2714 JavaScript\uff08\u6d4f\u89c8\u5668\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;...xml.childNodes].forEach(n =&gt; {\n    if (n.nodeType === Node.PROCESSING_INSTRUCTION_NODE) {\n        console.log(n.target, n.data);\n    }\n});\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u516d\u3001\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff08\u6700\u5e38\u89c1 3 \u7c7b\uff09<\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. XML + XSLT \u5c55\u793a\u7f51\u9875\uff08\u7ecf\u5178\u7528\u6cd5\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?xml-stylesheet type=&quot;text\/xsl&quot; href=&quot;news.xsl&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u4e13\u6709\u8f6f\u4ef6\u7684\u63a7\u5236\u6307\u4ee4<\/h2>\n\n\n\n<p>\u5982 PDF \u8f6c\u6362\u5de5\u5177\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?pdf page-size=&quot;A4&quot; margin=&quot;10&quot;?&gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u5d4c\u5165 PHP\/\u6a21\u677f\u5f15\u64ce<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;?php echo $title; ?&gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcd8 \u4e03\u3001\u603b\u7ed3\uff08\u91cd\u8981\u6982\u5ff5\u56de\u987e\uff09<\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Processing Instruction = \u7ed9\u5e94\u7528\u7a0b\u5e8f\u770b\u7684\u6307\u4ee4\uff0c\u4e0d\u662f XML \u7684\u4e00\u90e8\u5206\u3002<\/strong><\/li>\n\n\n\n<li>\u683c\u5f0f\uff1a<code>&lt;?target data?><\/code><\/li>\n\n\n\n<li><code>xml<\/code> \u4e0d\u80fd\u4f5c\u4e3a target\u3002<\/li>\n\n\n\n<li>PI \u4e0d\u5f71\u54cd XML \u7ed3\u6784\u3002<\/li>\n\n\n\n<li>\u6d4f\u89c8\u5668\u3001\u8f6c\u6362\u5668\u3001\u7f16\u8f91\u5668\u53ef\u6839\u636e PI \u6267\u884c\u7279\u6b8a\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li>\u6700\u5e38\u7528\u7684\u5904\u7406\u6307\u4ee4\u662f\uff1a<br><strong><code>&lt;?xml-stylesheet ... ?><\/code><\/strong><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd\u7b80\u6d01\u660e\u4e86\u3001\u5feb\u901f\u5165\u95e8\u7684\u300aXML \u5904\u7406\u6307\u4ee4\uff08Processing Ins&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/24\/%e7%ae%80%e5%8d%95%e4%ba%86%e8%a7%a3xml%e4%b8%ad%e7%9a%84%e5%a4%84%e7%90%86%e6%8c%87%e4%bb%a4\/\">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-131","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\/131","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=131"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}