{"id":4726,"date":"2021-08-06T09:17:01","date_gmt":"2021-08-06T09:17:01","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=4726"},"modified":"2021-08-06T09:17:01","modified_gmt":"2021-08-06T09:17:01","slug":"xml-dom-obhod","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/en\/xml-dom-obhod\/","title":{"rendered":"XML DOM \u2014 \u043e\u0431\u0445\u043e\u0434"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043c XML DOM Traversing.\u00a0\u0412\u00a0\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0433\u043b\u0430\u0432\u0435\u00a0\u043c\u044b \u0438\u0437\u0443\u0447\u0430\u043b\u0438, \u043a\u0430\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c XML-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442 DOM.\u00a0\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 DOM \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0439\u0434\u0435\u043d.\u00a0\u041e\u0431\u0445\u043e\u0434 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u043e\u0445\u043e\u0434\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u043e \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0443\u0437\u043b\u043e\u0432.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 (traverse_example.htm) \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0445\u043e\u0434 DOM.&nbsp;\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0443\u0437\u0435\u043b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 &lt;Employee&gt;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n   &lt;style&gt;\n      table,th,td {\n         border:1px solid black;\n         border-collapse:collapse\n      }\n   &lt;\/style&gt;\n   &lt;body&gt;\n      &lt;div id = \"ajax_xml\"&gt;&lt;\/div&gt;\n      &lt;script&gt;\n         \/\/if browser supports XMLHttpRequest\n         if (window.XMLHttpRequest) {\/\/ Create an instance of XMLHttpRequest object. \n            code for IE7+, Firefox, Chrome, Opera, Safari\n            var xmlhttp = new XMLHttpRequest();\n         } else {\/\/ code for IE6, IE5\n            var xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");\n         }\n         \/\/ sets and sends the request for calling \"node.xml\"\n            xmlhttp.open(\"GET\",\"\/dom\/node.xml\",false);\n            xmlhttp.send();\n\n         \/\/ sets and returns the content as XML DOM\n            var xml_dom = xmlhttp.responseXML;\n\t\n         \/\/ this variable stores the code of the html table\n            var html_tab = '&lt;table id = \"id_tabel\" align = \"center\"&gt;\n            &lt;tr&gt;\n               &lt;th&gt;Employee Category&lt;\/th&gt;\n               &lt;th&gt;FirstName&lt;\/th&gt;\n               &lt;th&gt;LastName&lt;\/th&gt;\n               &lt;th&gt;ContactNo&lt;\/th&gt;\n               &lt;th&gt;Email&lt;\/th&gt;\n            &lt;\/tr&gt;';\n            var arr_employees = xml_dom.getElementsByTagName(\"Employee\");\n         \/\/ traverses the \"arr_employees\" array\n            for(var i = 0; i&lt;arr_employees.length; i++) {\n               var employee_cat = arr_employees[i].getAttribute('category');\n   \n               \/\/ gets the value of 'category' element of current \"Element\" tag\n\n               \/\/ gets the value of first child-node of 'FirstName' \n               \/\/ element of current \"Employee\" tag\n                  var employee_firstName =\n                     arr_employees[i].getElementsByTagName('FirstName')[0].childNodes[0].nodeValue;\n\n               \/\/ gets the value of first child-node of 'LastName' \n               \/\/ element of current \"Employee\" tag\n                  var employee_lastName =\n                     arr_employees[i].getElementsByTagName('LastName')[0].childNodes[0].nodeValue;\n\n               \/\/ gets the value of first child-node of 'ContactNo' \n               \/\/ element of current \"Employee\" tag\n                  var employee_contactno = \n                     arr_employees[i].getElementsByTagName('ContactNo')[0].childNodes[0].nodeValue;\n\n               \/\/ gets the value of first child-node of 'Email' \n               \/\/ element of current \"Employee\" tag\n                  var employee_email = \n                     arr_employees[i].getElementsByTagName('Email')[0].childNodes[0].nodeValue;\n\n               \/\/ adds the values in the html table\n               html_tab += '&lt;tr&gt;\n                  &lt;td&gt;'+ employee_cat+ '&lt;\/td&gt;\n                  &lt;td&gt;'+ employee_firstName+ '&lt;\/td&gt;\n                  &lt;td&gt;'+ employee_lastName+ '&lt;\/td&gt;\n                  &lt;td&gt;'+ employee_contactno+ '&lt;\/td&gt;\n                  &lt;td&gt;'+ employee_email+ '&lt;\/td&gt;\n               &lt;\/tr&gt;';\n            }\n         html_tab += '&lt;\/table&gt;'; \n         \/\/ adds the html table in a html tag, with id = \"ajax_xml\"\n         document.getElementById('ajax_xml').innerHTML = html_tab; \n      &lt;\/script&gt;\n   &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442&nbsp;<a target=\"_blank\" href=\"https:\/\/www.tutorialspoint.com\/dom\/node.xml\" rel=\"noreferrer noopener\">node.xml<\/a>&nbsp;.<\/li><li>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 XML \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 JavaScript XML DOM.<\/li><li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 (\u0441 \u0442\u0435\u0433\u043e\u043c Element) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 getElementsByTagName ().<\/li><li>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u00a0<a target=\"_blank\" href=\"https:\/\/www.tutorialspoint.com\/dom\/node.xml\" rel=\"noreferrer noopener\">node.xml<\/a>\u00a0.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 XML \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 JavaScript XML DOM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 (\u0441 \u0442\u0435\u0433\u043e\u043c Element) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 getElementsByTagName ().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043c XML DOM Traversing.\u00a0\u0412\u00a0\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0433\u043b\u0430\u0432\u0435\u00a0\u043c\u044b \u0438\u0437\u0443\u0447\u0430\u043b\u0438, \u043a\u0430\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c XML-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442 DOM.\u00a0\u042d\u0442\u043e\u0442 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[152],"tags":[],"class_list":["post-4726","page","type-page","status-publish","hentry","category-xml-dom"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/4726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/comments?post=4726"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/4726\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/media?parent=4726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/categories?post=4726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/tags?post=4726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}