{"id":102,"date":"2012-11-08T13:01:25","date_gmt":"2012-11-08T05:01:25","guid":{"rendered":"http:\/\/www.yeetrack.com\/post\/2012-11-08\/php%2520xml%2520dom%25E8%25A7%25A3%25E9%2587%258A%25E5%2599%25A8"},"modified":"2013-04-20T17:28:21","modified_gmt":"2013-04-20T09:28:21","slug":"phpxmldom%e8%a7%a3%e9%87%8a%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=102","title":{"rendered":"php xml dom\u89e3\u91ca\u5668"},"content":{"rendered":"<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;php\u5904\u7406xml\u6587\u4ef6\uff0c\u9700\u8981xml\u89e3\u91ca\u5668\uff0c\u6709\u4e24\u79cd\u57fa\u672c\u7684xml\u89e3\u91ca\u5668\uff1a<\/p>\n<p><!--more--><\/p>\n<ul>\n<li>\n<p>\u57fa\u4e8e\u6811\u7684\u89e3\u91ca\u5668\uff1a\u8fd9\u79cd\u89e3\u91ca\u5668\u628axml\u6587\u4ef6\u8f6c\u5316\u4e3a\u6811\u5f62\u7ed3\u6784\u3002\u5b83\u5206\u6790\u6574\u7bc7\u6587\u4ef6\uff0c\u63d0\u4f9bAPI\u6765\u8bbf\u95ee\u6811\u7684\u5143\u7d20\u3002<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u57fa\u4e8e\u4e8b\u4ef6\u7684\u89e3\u91ca\u5668\uff1a\u5c06xml\u6587\u4ef6\u770b\u6210\u4e00\u7cfb\u5217\u7684\u4e8b\u4ef6\u3002\u5f53\u67d0\u4e2a\u5177\u4f53\u7684\u4e8b\u4ef6\u53d1\u751f\u65f6\uff0c\u89e3\u91ca\u5668\u5c31\u4f1a\u8c03\u7528\u76f8\u5e94\u7684\u51fd\u6570\u6765\u5904\u7406\u3002<\/p>\n<\/li>\n<\/ul>\n<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dom\u89e3\u91ca\u5668\u5c31\u662f\u57fa\u4e8e\u6811\u7684\u89e3\u91ca\u5668\u3002\u4e0b\u9762\u662f\u4e00\u4e2axml\u6587\u4ef6\uff1a<\/p>\n<pre config=\"brush:html;toolbar:false;\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;\n&lt;yeetrack&gt;\n&lt;name&gt;yeetrack&lt;\/name&gt;\n&lt;domain&gt;www.yeetrack.com&lt;\/domain&gt;\n&lt;content&gt;The security of network&lt;\/content&gt;\n&lt;\/yeetrack&gt;<\/pre>\n<p>xml dom\u4f1a\u628axml\u6587\u4ef6\u89c6\u4e3a\u4e00\u4e2a\u6811\u5f62\u7ed3\u6784\uff1a<\/p>\n<ul>\n<li>\n<p>Level 1\uff1a xml\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>Level 2\uff1a\u6839\u5143\u7d20&lt;yeetrack&gt;\u3001&lt;name&gt;\u7b49<\/p>\n<\/li>\n<li>\n<p>Level 3: &nbsp;\u6587\u672c\u5143\u7d20\uff1ayeetrack<\/p>\n<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u662f\u8bfb\u53d6xml\u6587\u4ef6\u7684\u4ee3\u7801\uff1a<\/p>\n<pre config=\"brush:php;toolbar:false;\">&lt;?php\n        $xmlDoc = new DOMDocument(); \/\/\u521d\u59cb\u5316\u4e00\u4e2axml\u89e3\u91ca\u5668\n        $xmlDoc-&gt;load(&quot;data.xml&quot;); \/\/\u52a0\u8f7dxml\u6587\u4ef6\n        print $xmlDoc-&gt;saveXML();  \/\/\u8f93\u51faxml\u6587\u4ef6\necho &quot;\n&quot;;\n           \n   \n   \n\/\/\u4e0b\u9762\u5faa\u73af\u8f93\u5165xml\u7684\u6bcf\u4e2a\u8282\u70b9\n        $element = $xmlDoc-&gt;documentElement;\/\/\u83b7\u53d6xml\u6839\u8282\u70b9\n           \n        foreach ($element-&gt;childNodes AS $item) \/\/\u5faa\u73af\u83b7\u53d6\u5b50\u8282\u70b9\n                print $item-&gt;nodeName . &quot;=&quot; . $item-&gt;nodeValue . &quot;\n&quot;;\n?&gt;<\/pre>\n<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xml\u5728\u751f\u6210\u65f6\uff0c\u4f1a\u5728\u8282\u70b9\u4e4b\u95f4\u5305\u542b\u7a7a\u767d\u3002xml Dom\u89e3\u91ca\u5668\u4f1a\u628a\u5b83\u4eec\u5f53\u505a\u666e\u901a\u5143\u7d20\u5904\u7406\uff0c\u9700\u8981\u6ce8\u610f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;php\u5904\u7406xml\u6587\u4ef6\uff0c\u9700\u8981xml\u89e3\u91ca\u5668\uff0c\u6709\u4e24\u79cd\u57fa\u672c\u7684xml\u89e3\u91ca\u5668\uff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[24,7],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-coding","tag-php","tag-7"],"views":2384,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":413,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/413"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}