XML DOM 节点

网友投稿 456 2022-05-29

XML DOM 把 XML 文档视为一棵节点树。

树中的所有节点彼此之间都有关系。

XML DOM 节点树

XML DOM 把 XML 文档视为一种树结构。这种树结构被称为节点树。

可通过这棵树访问所有节点。可以修改或删除它们的内容,也可以创建新的元素。

这颗节点树展示了节点的集合,以及它们之间的联系。这棵树从根节点开始,然后在树的最低层级向文本节点长出枝条:

上面的图片表示 XML 文件 books.xml。

XML DOM 节点树

父节点、子节点和同级节点

节点树中的节点彼此之间都有层级关系。

父节点、子节点和同级节点用于描述这种关系。父节点拥有子节点,位于相同层级上的子节点称为同级节点(兄弟或姐妹)。

在节点树中,顶端的节点称为根节点

根节点之外的每个节点都有一个父节点

节点可以有任何数量的子节点

叶子是没有子节点的节点

同级节点是拥有相同父节点的节点

下面的图片展示出节点树的一个部分,以及节点间的关系:

因为 XML 数据是按照树的形式进行构造的,所以可以在不了解树的确切结构且不了解其中包含的数据类型的情况下,对其进行遍历。

您将在本教程稍后的章节学习更多有关遍历节点树的知识。

第一个子节点 - 最后一个子节点

请看下面的 XML 片段:

Everyday Italian Giada De Laurentiis 2005 30.00

在上面的 XML 中, 元素是 <book> 元素的第一个子节点,而 <price> 元素是 <book> 元素的最后一个子节点。</p><p>此外,<book> 元素是 <title>、<author>、<year> 和 <price> 元素的父节点。</p><p>XML</p><p> <strong>版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。</strong> </p></div> <div class="article_footer clear"> <div class="fr tag">标签:<a href="https://www.huoban.com/news/tags-5538.html">XML DOM</a> <a href="https://www.huoban.com/news/tags-1253.html">节点</a> </div> <div class="bdsharebuttonbox fl share"> <div class="share-widget fl"> <div class="social-share" data-sites="wechat,weibo, qq, qzone"></div> </div> </div> </div> <!-- 广告位ad4 --> <div class="post-navigation clear"> <div class="post-previous fl"> <span>上一篇:</span><a href="https://www.huoban.com/news/post/11145.html">【 MATLAB 】信号处理工具箱之波形产生函数 rectpuls</a> </div> <div class="post-next fr"> <span>下一篇:</span><a href="https://www.huoban.com/news/post/11147.html">requests 的安装</a> </div> </div> </div> <div class="related_article"> <div class="box_title clear"> <span><i class="icon fa fa-paper-plane"></i>相关文章</span> </div> <div class="related_list clear"> <article class="fl"> <div class="related_img"><a href="https://www.huoban.com/news/post/45907.html"><img src="https://www.huoban.com/news/zb_users/upload/2022/06/20220623084026_70253.jpg"></a></div> <div class="related_detail"> <h3><a href="https://www.huoban.com/news/post/45907.html" title="excel折线图节点怎么改形状">excel折线图节点怎么改形状</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>456</span> <span><i class="fa fa-clock-o"></i>2022-05-29</span> </div> </div> </article> <article class="fl"> <div class="related_img"><a href="https://www.huoban.com/news/post/18276.html"><img src="https://www.huoban.com/news/zb_users/cache/ly_autoimg/m/MTgyNzY.jpg"></a></div> <div class="related_detail"> <h3><a href="https://www.huoban.com/news/post/18276.html" title="Nginx后端节点可用性探测和配置实操">Nginx后端节点可用性探测和配置实操</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>456</span> <span><i class="fa fa-clock-o"></i>2022-05-29</span> </div> </div> </article> <article class="fl"> <div class="related_img"><a href="https://www.huoban.com/news/post/17556.html"><img src="https://www.huoban.com/news/zb_users/cache/ly_autoimg/m/MTc1NTY.jpg"></a></div> <div class="related_detail"> <h3><a href="https://www.huoban.com/news/post/17556.html" title="驾驭千级节点——揭秘PUMA大规模集群能力(一) ——需求分析">驾驭千级节点——揭秘PUMA大规模集群能力(一) ——需求分析</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>456</span> <span><i class="fa fa-clock-o"></i>2022-05-29</span> </div> </div> </article> </div> </div> <!--<p class="comment-disable sb br mb"><i class="iconfont icon-cry"></i>抱歉,评论功能暂时关闭!</p>--> </div> </div> <div class="sidebar"> <div id="推荐文章" class="part clear 推荐文章"> <div class="top"> <h3 class="title">推荐文章</h3> </div> <div class="side 推荐文章"><ul><ul class="hot_posts"> <li><h4><a href="https://www.huoban.com/news/post/132763.html" title="企业生产管理是什么,企业生产管理软件">企业生产管理是什么,企业生产管理软件</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/136160.html" title="盘点进销存软件排行榜前十名">进盘点进销存软件排行榜前十名</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132779.html" title="进销存系统哪个简单好用?进销存系统优点">进销存系统哪个简单好用?进销存系统优点</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/133648.html" title="工厂生产管理(工厂生产管理流程及制度)">工厂生产管理(工厂生产管理流程及制度)</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132780.html" title="生产管理软件,机械制造业生产管理,制造业生产过程管理软件">生产管理软件,机械制造业生产管理,制造业生产过程管理软件</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132776.html" title="进销存软件和ERP有什么区别?进销存与erp软件理解">进销存软件和ERP有什么区别?进销存与erp软件理解</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132974.html" title="进销存如何进行库存管理">进销存如何进行库存管理</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132269.html" title="excel销售订单管理系统(销售订单录入系统)">如何利用excel制作销售订单管理系统?</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/136946.html" title="数据库订单管理系统有哪些功能?数据库订单管理系统怎么设计?">数据库订单管理系统有哪些功能?数据库订单管理系统怎么设计?</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/132312.html" title="数据库订单管理系统(订单系统数据流图)">什么是数据库管理系统?</a></h4></li></ul></ul></div> </div> <div id="divPrevious" class="part clear previous"> <div class="top"> <h3 class="title">最近发表</h3> </div> <div class="side divPrevious"><ul><li><a title="Excel在线破解网站,解锁你的数据潜能!" href="https://www.huoban.com/news/post/155583.html">Excel在线破解网站,解锁你的数据潜能!</a></li> <li><a title="如何使用numbers在线转换为excel文件" href="https://www.huoban.com/news/post/155582.html">如何使用numbers在线转换为excel文件</a></li> <li><a title="CRM软件的崛起及其在企业管理中的重要性" href="https://www.huoban.com/news/post/155581.html">CRM软件的崛起及其在企业管理中的重要性</a></li> <li><a title="选择适合的CRM软件,企业成功的关键因素" href="https://www.huoban.com/news/post/155580.html">选择适合的CRM软件,企业成功的关键因素</a></li> <li><a title="工程项目管理系统在提升项目管理效率中的关键作用" href="https://www.huoban.com/news/post/155579.html">工程项目管理系统在提升项目管理效率中的关键作用</a></li> <li><a title="Excel,快速解决你的疑虑并提升工作效率" href="https://www.huoban.com/news/post/155578.html">Excel,快速解决你的疑虑并提升工作效率</a></li> <li><a title="Excel在线咨询,提供个性化的Excel咨询服务" href="https://www.huoban.com/news/post/155577.html">Excel在线咨询,提供个性化的Excel咨询服务</a></li> <li><a title="excel在线提问,快速解答您的Excel疑惑!" href="https://www.huoban.com/news/post/155576.html">excel在线提问,快速解答您的Excel疑惑!</a></li> <li><a title="在线共享Excel" href="https://www.huoban.com/news/post/155575.html">在线共享Excel</a></li> <li><a title="erp管理系统在当今企业管理中的重要性与实施挑战" href="https://www.huoban.com/news/post/155574.html">erp管理系统在当今企业管理中的重要性与实施挑战</a></li> </ul></div> </div> <div id="sidebar_ad" class="part clear sidebar_ad"> <div class="part sidebar_ad"><div class="active"><a href='https://mrhnug.r.huobanbot.com/wxwork/pub/landings/426?app_id=1960&company_id=54&corp_id=wwbd4b7b6e7b0ccdaa&app_company_id=1' target='_blank'><img style='width:100%;height:100%' src='https://www.huoban.com/news/zb_users/upload/2023/08/erwei3.jpg'></a><br> <a href='https://www.huoban.com/crm.html?utm=jiasouadv' target='_blank'><img style='width:100%;height:100%' src='https://www.huoban.com/news/zb_users/upload/2023/03/20230321171645167939020583758.png'></a><br> </div></div> </div> <div id="hot_posts" class="part clear hot_posts"> <div class="top"> <h3 class="title">热评文章</h3> </div> <ul class="hot_posts"><li><h4><a href="https://www.huoban.com/news/post/104011.html" title="零代码开发是什么?2022低代码平台排行榜">零代码开发是什么?2022低代码平台排行榜</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/131019.html" title="智能进销存库存管理系统(智慧进销存)">智能进销存库存管理系统(智慧进销存)</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/73907.html" title="在线文档哪家强?8款在线文档编辑软件推荐">在线文档哪家强?8款在线文档编辑软件推荐</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/102663.html" title="WPS2016怎么绘制简单的价格表?">WPS2016怎么绘制简单的价格表?</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/143685.html" title="定制家居数字化管理模式:提升品质、智能化和个性化的未来">定制家居数字化管理模式:提升品质、智能化和个性化的未</a></h4></li><li><h4><a href="https://www.huoban.com/news/post/35776.html" title="什么是在线文档?怎么发在线文档">什么是在线文档?怎么发在线文档</a></h4></li></ul> </div> <div id="divLinkage" class="part clear link"> <div class="top"> <h3 class="title">友情链接</h3> </div> <div class="side divLinkage"><ul><li class="link-item"><a href="https://www.huoban.com/" target="_blank" title="伙伴云">伙伴云</a></li><li class="link-item"><a href="https://www.huoban.com/news/category-19.html" title="进销存管理">进销存管理</a></li><li class="link-item"><a href="https://www.huoban.com/news/category-3.html" title="低代码">低代码</a></li><li class="link-item"><a href="https://www.huoban.com/news/tags-12.html" target="_blank" title="Excel表格">Excel表格</a></li></ul></div> </div> </div> </div> </section> </div> <footer class="p-footer"> <div class="contant_box"> <div class="discover_tmt"> <h5 class="">伙伴云</h5> <div class="text_box"> <a href="https://jiasou.cn/" title="2B数字化营销SEO">加搜toBSEO</a> <a href="https://www.eulee.cn/article/" title="三维数据引擎">产业元宇宙资讯</a> <a href="https://www.weiling.cn/info/" title="客户营销管理资讯中心">卫瓴CRM资讯</a> <a href="https://www.zkj.com/news/" title="外呼系统新闻资讯中心">外呼系统资讯</a> <a href="https://www.finclip.com/news/category-1.html" title="小程序工具">前端框架</a> <a href="https://www.xinfushe.com/article/" title="灵活用工资讯">灵活用工资讯</a> <a href="http://www.weihusm.com/" title="阿伟常识网">阿伟常识网</a> <a href="http://www.ruishiqiba.com/" title="懂球帝旅游网">懂球帝旅游网</a> </div> </div> <div class="collaboration_box"> </div> <div class="we_img_box clear"> <div class="img_box"> <img src="https://www.huoban.com/news/zb_users/theme/zblog5_news/image/ewm.png" alt="" class="hover_tmt"> </div> </div> </div> <p class="info"> <a href="https://beian.miit.gov.cn" target="_blank" rel="nofollow">京ICP备12038259号</a> <span> <a href="#"></a></span> </p> </footer> <div id="backtop" class="backtop"> <div class="bt-box top"> <i class="fa fa-angle-up fa-2x"></i> </div> </div> <script charset="UTF-8" src="https://www.huoban.com/assets/js/sensorsdata.1.22.2.min.js"></script> <script charset="UTF-8"> var sensors = window['sensorsDataAnalytic201505']; sensors.init({ server_url: 'https://saapi.huoban.com/sa?project=production', heatmap:{scroll_notice_map:'not_collect'}, use_client_time:true, send_type:'beacon' }); sensors.quick('autoTrack'); </script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?6444c045836d6bf27124085a4f62c2a8"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script> (()=>{const e="https://analyze.jiasou.cc/api/v1/page_view/report/",n="9fe06d4884e0461caaa1de5651164d43";let t=null;const o=new Proxy({},{get:(e,n)=>localStorage.getItem(window.btoa(n)),set:(e,n,t)=>!!t&&(localStorage.setItem(window.btoa(n),t),!0)});new Promise((t=>{if(o.fingerprint)t();else{const a=function(){var e={};if(e.userAgent=navigator.userAgent||"",e.plugins=[],navigator.plugins&&navigator.plugins.length>0)for(var n=0;n<navigator.plugins.length;n++){var t={name:navigator.plugins[n].name||"",filename:navigator.plugins[n].filename||"",description:navigator.plugins[n].description||""};e.plugins.push(t)}e.languages=navigator.languages||[navigator.language||""],e.timezone=(new Date).getTimezoneOffset(),e.screenResolution={width:window.screen.width||0,height:window.screen.height||0,pixelDepth:window.screen.pixelDepth||0,colorDepth:window.screen.colorDepth||0};var o=document.createElement("canvas").getContext("2d"),a=[],i=["monospace","sans-serif","serif"];for(n=0;n<i.length;n++){var r=i[n];o.font="12px "+r,o.measureText("abcdefghijklmnopqrstuvwxyz0123456789").width>0&&a.push(r)}return e.fonts=a,e.cookieEnabled=navigator.cookieEnabled||!1,e.localStorage=void 0!==window.localStorage,e.sessionStorage=void 0!==window.sessionStorage,e.doNotTrack="1"===navigator.doNotTrack||"1"===window.doNotTrack||"1"===navigator.msDoNotTrack||"yes"===navigator.doNotTrack,e}();fetch(`${e}u/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:n,f:window.btoa(JSON.stringify(a))})}).then((e=>{console.debug("browser fingerprint sent"),200===e.status&&e.json().then((e=>{console.debug("browser fingerprint received",e),o.fingerprint=e.fp,t()}))}))}})).then((()=>{e&&o.fingerprint&&fetch(e+`?${new URLSearchParams({token:n}).toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({c:window.btoa(JSON.stringify({u:o.fingerprint,l:window.location.href,r:document.referrer}))})}).then((e=>{200==e.status&&e.json().then((e=>{e.track_id&&(t=e.track_id)}))}))})),window.addEventListener("beforeunload",(async n=>{t&&fetch(e+`?${new URLSearchParams({track_id:t}).toString()}`,{method:"GET",headers:{"Content-Type":"text/plain"},keepalive:!0}),n.returnValue=""}))})(); </script><script language="javascript" src="https://www.huoban.com/news/zb_users/plugin/ZF_ad/js/index.js?id=406"></script> <script language="javascript" src="https://www.huoban.com/news/zb_users/plugin/ZF_ad/js/ZF_ad__cookie.js"></script> </body> </html> <!--165.02 ms , 18 queries , 3674kb memory , 0 error-->