以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  在xml中跟节点是怎么看的?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=17962)


--  作者:luckerdzr
--  发布时间:5/8/2005 1:39:00 PM

--  在xml中跟节点是怎么看的?
slideSample01.xml

<?xml version='1.0' encoding='utf-8'?>

<!--  A SAMPLE set of slides  -->

<slideshow
    title="Sample Slide Show"
    date="Date of publication"
    author="Yours Truly"
    >

    <!-- TITLE SLIDE -->
    <slide type="all">
      <title>Wake up to WonderWidgets!</title>
    </slide>

    <!-- OVERVIEW -->
    <slide type="all">
      <title>Overview</title>
      <item>Why <em>WonderWidgets</em> are great</item>
      <item/>
      <item>Who <em>buys</em> WonderWidgets</item>
    </slide>

</slideshow>

执行
root=doc.getDocumentElement();
得到的根节点是 slideshow
那么
<!--  A SAMPLE set of slides  -->
这句注释在这里算什么呢?


--  作者:Qr
--  发布时间:5/8/2005 5:03:00 PM

--  
根节点就是 slideshow,

<!--  A SAMPLE set of slides  -->
就是注释,不会被认为是根节点。


--  作者:luckerdzr
--  发布时间:5/8/2005 5:29:00 PM

--  
那为什么象
<!-- TITLE SLIDE -->
这些又算节点了呢。

是不是根节点不能由comment类型的?
那我怎么读在根节点之上的comment的内容呢?


--  作者:Qr
--  发布时间:5/8/2005 5:36:00 PM

--  
在XSL中可以读的,<xsl:comment>好象是这样吧,翻手册看看,很少用。
--  作者:残墨
--  发布时间:6/10/2005 11:23:00 AM

--  
<!--注释-->

没什么意义的,用来说明而已。就像你在编程中用的// 、/*   */注释一样。


--  作者:binaryluo
--  发布时间:6/13/2005 9:45:00 AM

--  
跟节点就是开始标记和结束标记的成对出现的最外层的那个标记。例如:
<?xml ....  ?>
<!-- .... -->
<root>
   ....
</root>
root就是跟节点。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,472.656ms