热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

XML中的根节点是什么?-WhatistherootnodeinXML?

Iwasreadinganebookandithasfollowingxmlcode.我正在阅读一本电子书,它有以下xml代码。<?xmlversion1.0?

I was reading an ebook and it has following xml code.

我正在阅读一本电子书,它有以下xml代码。





  
  
  
  
  
  
  
  
  
  
]>



  
    Shakespeare
    William
    British
    1564
    1616
  
  
  
  
    My mistress' eyes are nothing like the sun,
    Coral is far more red than her lips red.
    If snow be white, why then her breasts are dun,
    If hairs be wires, black wires grow on her head.
    I have seen roses damasked, red and white,
    But no such roses see I in her cheeks.
    And in some perfumes is there more delight
    Than in the breath that from my mistress reeks.
    I love to hear her speak, yet well I know
    That music hath a far more pleasing sound.
    I grant I never saw a goddess go,
    My mistress when she walks, treads on the ground.
    And yet, by Heaven, I think my love as rare
    As any she belied with false compare.
  


problem is when I continue the rest of the reading I thought I have misunderstand what root element is. According to my knoweledge root node is node.

问题是,当我继续阅读其余部分时,我认为我误解了根元素是什么。根据我的知识,根节点是 节点。

But in the book I find next this

但在书中,我发现了下一个

Unlike other nodes, the root node has no parent. It always has at least one child, the document element. The root node also contains comments or processing instructions that are outside the document element. In our sample document, the two processing instructions named xmlstylesheet and cocoon-process are both children of the root node, as are the comment that appears before the tag and the comment that appears after the tag.

与其他节点不同,根节点没有父节点。它始终至少有一个子元素,即文档元素。根节点还包含文档元素之外的注释或处理指令。在我们的示例文档中,名为xmlstylesheet和cocoon-process的两个处理指令都是根节点的子节点,标记之前显示的注释和标记之后显示的注释也是如此。

accordning to that whole document is considered as root. If so what is ? It is clear that processing instructions and comments are not child of node.

根据整个文件被视为根。如果是的话是什么?很明显,处理指令和注释不是节点的子节点。

do I minunderstand?

我最小化吗?

UPdate

更新

 
 
   Vegetable
   Fruits
   other

what is the root element here? isnt it food?

这里的根元素是什么?不是食物吗?

1 个解决方案

#1


14  

The root node has no visual manifestation or textual representation. It is a conceptual node that contains everything else in the document. In the example of your document, it would be like this:

根节点没有可视表现或文本表示。它是一个概念节点,包含文档中的所有其他内容。在您的文档示例中,它将是这样的:

/ (root node)
   |-- processing-instruction() xml-stylesheet
   |-- processing-instruction() cocoon-process 
   |-- comment()
   |-- comment()
   |-- sonnet   (document element)
        |-- auth:author
             |-- last-name
             |-- ....
        |-- comment()
        |-- title
        |-- lines
             |-- line
             |-- line
             |-- ....
   |-- comment()
   |-- comment()

As shown here, the root node in your example has 2 processing instructions, 4 comments, and 1 element as children.

如此处所示,示例中的根节点有2个处理指令,4个注释和1个子元素。

This single child element (sonnet) is what's called the "document element". It's also sometimes called the "root element", but many people like to avoid this term to minimize confusion with the "root node", since they are two completely separate things.

这个单个子元素(十四行诗)就是所谓的“文档元素”。它有时也被称为“根元素”,但许多人喜欢避免使用这个术语来最大限度地减少与“根节点”的混淆,因为它们是两个完全不同的东西。


推荐阅读
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • 本文介绍了Perl的测试框架Test::Base,它是一个数据驱动的测试框架,可以自动进行单元测试,省去手工编写测试程序的麻烦。与Test::More完全兼容,使用方法简单。以plural函数为例,展示了Test::Base的使用方法。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
  • Android系统移植与调试之如何修改Android设备状态条上音量加减键在横竖屏切换的时候的显示于隐藏
    本文介绍了如何修改Android设备状态条上音量加减键在横竖屏切换时的显示与隐藏。通过修改系统文件system_bar.xml实现了该功能,并分享了解决思路和经验。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • 本文介绍了C++中省略号类型和参数个数不确定函数参数的使用方法,并提供了一个范例。通过宏定义的方式,可以方便地处理不定参数的情况。文章中给出了具体的代码实现,并对代码进行了解释和说明。这对于需要处理不定参数的情况的程序员来说,是一个很有用的参考资料。 ... [详细]
  • Android Studio Bumblebee | 2021.1.1(大黄蜂版本使用介绍)
    本文介绍了Android Studio Bumblebee | 2021.1.1(大黄蜂版本)的使用方法和相关知识,包括Gradle的介绍、设备管理器的配置、无线调试、新版本问题等内容。同时还提供了更新版本的下载地址和启动页面截图。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 本文介绍了在Mac上搭建php环境后无法使用localhost连接mysql的问题,并通过将localhost替换为127.0.0.1或本机IP解决了该问题。文章解释了localhost和127.0.0.1的区别,指出了使用socket方式连接导致连接失败的原因。此外,还提供了相关链接供读者深入了解。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
author-avatar
小辉0110_737
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有