非常游戏网
XPath的comment()如何选择注释节点?

XPath的comment()如何选择注释节点?

2025-08-17日常编程165978

答案:XPath中comment()函数用于选择注释节点,与text()不同,前者提取内的内容,后者获取元素内的文本;可通过//comment()获取所有注释,或结合轴、谓词和字符串函数精确筛选目标注释。

XPath中,

comment()

函数专门用来选择文档中的注释节点。它就像一个过滤器,只把那些被

包裹起来的内容找出来,而忽略元素、属性或文本节点。

解决方案

说实话,处理XML或HTML里的注释节点,XPath的

comment()

函数是个非常直接的工具。它不关心注释里面写了什么,只要是注释,它就能帮你抓出来。

最基础的用法,如果你想获取文档中所有的注释节点,无论它们藏在哪里,直接用

//comment()

就行了。这就像在整个文档里撒网,所有符合“注释”这个条件的,都会被捞上来。



    
        
        内容
    
    

对应上面的XML,

//comment()

会返回三个注释节点。

如果你只想获取特定元素下的注释,那路径就得具体一点。比如,只想找


元素下面的注释,可以写成

/root/element/comment()

。这会只返回“元素内部的注释”那个节点。

有时候,我们不光要找到注释,可能还想看看它里面写了什么。XPath的强大之处在于,找到节点后,你还能对其内容进行判断。虽然

comment()

本身只是选择节点,但你可以通过谓词(

[]

)来进一步筛选。比如,你想找内容包含特定文本的注释,就可以这么写:

//comment()[contains(., '特定文本')]

。这里的

.

代表当前节点(也就是注释节点)的字符串值。

这听起来简单,但在实际操作中,注释的内容往往很随意,可能包含换行符、多余空格,甚至是一些非标准字符。所以,精确匹配有时候会是个小挑战。我的经验是,如果注释内容是人工维护的,那往往不那么规范,需要多尝试几种匹配方式。

如何精确筛选特定内容的注释节点?

要精确筛选特定内容的注释节点,光靠

comment()

本身是不够的,我们需要结合XPath的字符串函数和谓词来做文章。这就像给你的渔网加上了更细的网眼,只捕捞你真正想要的“鱼”。

最常用的方法就是使用

contains()

函数。比如,你有一个注释写着

,你想找到所有包含“用户信息”的注释,可以这样写:

//comment()[contains(., '用户信息')]

。这里的点号

.

代表当前注释节点的内容。

但如果你的注释内容很长,或者有多种变体,比如

,你可能需要更灵活的匹配方式。XPath 2.0及更高版本提供了

matches()

函数,它支持正则表达式,这简直是精确匹配的利器。例如,

//comment()[matches(., '用户(信息|数据)')]

可以匹配包含“用户信息”或“用户数据”的注释。不过,要注意的是,很多老旧的XPath解析器(比如一些浏览器内置的)可能只支持XPath 1.0,那就用不了

matches()

了。

还有一种情况,注释内容可能包含多余的空格或者换行符。例如:

如果你直接用

contains(., '多行注释')

,通常是没问题的,因为XPath在处理字符串值时会把这些空白字符都包含进去。但如果你想匹配一个非常精确的字符串,比如“多行注释”,而注释里实际是“ 多行注释 ”(前面有空格),那你就得小心了。有时候,我会先用

normalize-space()

函数来清理注释内容的空白,再进行匹配,比如

//comment()[contains(normalize-space(.), '多行注释')]

。这样可以避免因为空白字符导致的匹配失败。但也要考虑实际情况,如果注释里故意留白是为了格式,那么

normalize-space()

可能会破坏你的意图。

所以,我的建议是,在编写匹配规则时,先仔细检查目标注释的实际内容,包括其内部的空白和换行符,再选择最合适的函数。

XPath的comment()与文本节点选择有何不同,何时使用它们?

comment()

text()

是XPath中两个非常重要但又截然不同的节点类型函数,它们各自有明确的职责。简单来说,

comment()

是找

这种形式的注释,而

text()

是找元素标签之间或属性值里的纯文本内容。它们俩是“井水不犯河水”的。

比如说,你有这样的XML:

    
    这是商品的具体描述。
    100

如果你用

//product/comment()

,你会得到“商品描述”那个注释节点。
但如果你用

//product/text()

,你会得到“这是商品的具体描述。”这部分文本。注意,

text()

只会返回直接子文本节点,像

100

里面的“100”就不是


的直接文本子节点,你需要用

//product/price/text()

才能取到它。

什么时候用哪个呢?这取决于你的目标。

  • 使用

    comment()

    当你需要获取文档中那些不直接参与数据结构、但可能包含元信息、调试信息、版权声明或者其他非结构化备注时。例如,网页抓取时,有些网站会把一些动态加载的URL或者API密钥放在注释里;或者在XML配置文件中,开发者会用注释来解释某个配置项的用途。这时候,

    comment()

    就是你的首选。它帮你把那些“悄悄话”找出来。

  • 使用

    text()

    当你需要提取元素内部的实际数据内容时。这是最常见的用法,比如从网页上抓取文章标题、商品价格、用户评论等。

    text()

    关注的是用户可见或业务逻辑相关的文本信息。

它们最大的不同在于语义和结构角色。注释是对文档的解释或备注,不属于文档的“内容”本身;而文本节点就是文档的“内容”。混淆它们会导致你获取到错误的数据,或者错过重要的信息。我的看法是,理解它们的本质差异,才能在复杂的文档结构中游刃有余地提取所需信息。有时候,一个元素内部既有文本又有注释,比如

一些文本

,你需要分别使用

comment()

text()

来获取它们。

处理复杂或嵌套结构中的注释节点有哪些高级技巧?

处理复杂或嵌套结构中的注释节点,不仅仅是找到它们,更重要的是理解它们与周围元素的相对位置和上下文关系。这就像在地图上找一个地标,不光要知道地标的名字,还要知道它在哪个街区,旁边有什么建筑物。

一个常见场景是,你可能想找到某个特定元素“前面”或者“后面”的注释。XPath提供了轴(axes)来描述节点之间的关系。

  • preceding-sibling::comment()

    查找当前节点之前的所有同级注释节点。比如,你想找到一个

    </pre>
    </div>
    </div>
    <p>元素前面紧挨着的注释,可以这样写:</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//title/preceding-sibling::comment()[1]</pre>
    </div>
    <p>(</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">[1]</pre>
    </div>
    <p>表示取最近的那个)。</p>
    </li>
    <li>
    <p><strong></p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">following-sibling::comment()</pre>
    </div>
    <p>:</strong> 查找当前节点之后的所有同级注释节点。类似地,</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//title/following-sibling::comment()[1]</pre>
    </div>
    <p>会找到紧跟在</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false"><title></pre>
    </div>
    </div>
    <p>后面的注释。</p>
    </li>
    </ul>
    <p>这在处理一些前端框架生成的HTML时特别有用,它们可能在组件的开始或结束位置插入注释,用于调试或标记。</p>
    <p>再复杂一点,如果注释不在同级,而是在某个祖先或后代中,但你又想根据某个特定的元素来定位它,那就要结合路径和谓词了。例如,你想找到所有包含“重要”字样的注释,但这些注释必须是某个</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false"><section id="main"></pre>
    </div>
    <p>元素内部的,不论它嵌套多深:</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//section[@id="main"]//comment()[contains(., '重要')]</pre>
    </div>
    <p>。这里</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//</pre>
    </div>
    <p>表示“任意后代”,它能穿透多层嵌套。</p>
    <p>有时候,注释可能作为某个元素的第一个或最后一个子节点出现。你可以用</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">*[1]</pre>
    </div>
    <p>或</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">last()</pre>
    </div>
    <p>这样的位置谓词来定位:</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//div/comment()[1]</pre>
    </div>
    <p>:获取</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">div</pre>
    </div>
    </div>
    <p>下的第一个子注释节点。</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">//div/comment()[last()]</pre>
    </div>
    <p>:获取</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false">div</pre>
    </div>
    </div>
    <p>下的最后一个子注释节点。</p>
    <p>另一个比较有意思的场景是,注释本身可能包含一些看起来像路径或者ID的信息。比如:</p>
    <div class="code" style="position:relative;padding:0px;margin:0px">
    <pre class="brush:php;toolbar:false"><!-- related-to: product-id-123 --></pre>
    </div>
    <p>。你可以提取这个“product-id-123”然后用它来做进一步的查询。这通常涉及到在XPath结果上进行字符串处理,或者在XPath 2.0+中使用更复杂的正则匹配来提取子串。</p>
    <p>我的经验告诉我,处理这些“隐藏”在注释里的信息,关键在于灵活运用XPath的轴、谓词和字符串函数。它们能让你像外科医生一样精准地定位和提取信息,即使这些信息被包裹在看似无关的注释里。但切记,注释的内容结构往往不规范,所以你的XPath表达式可能需要比处理标准元素内容时更具容错性。</p>
    <p>以上就是XPath的comment()如何选择注释节点?的详细内容,更多请关注非常游戏网【www.myinqi.com】。</p>
    </div>	</div>	
    	    
    <ul class="ul-list">
    <div class="listad"><li>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-6278534685681362"
         data-ad-slot="5195168813"
         data-ad-format="auto"
         data-full-width-responsive="true"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </li>
    </div>
    <h3 class="sidebar_title indexnew">相关推荐</h3>
    <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3428275/"><h6>Python 3.12中的类型注释有何变化_搭建支持新语法静态检测的环境</h6></a>
    		<div class="data"><span class="month">05月</span><span class="day">28</span><span class="year">2026</span></div>
            <div class="news-info">
            <p>Python3.12新增PEP695泛型语法(如classConfig[T]:)、type别名泛型(typeTree[T]=...)、TypeVardefault参数及Annotated元数据机制,需解释器3.12+与Pyright≥1.1.350/mypy≥1.10.0双向兼容支持。 Python3.12的类型注释本身没有破坏性变更,但新增的泛型语法(PEP695)和类型变量能力(如defaul...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3428158/"><h6>Python中SVM支持向量机如何选择核函数_对比Linear与RBF性能</h6></a>
    		<div class="data"><span class="month">05月</span><span class="day">27</span><span class="year">2026</span></div>
            <div class="news-info">
            <p>应优先用LinearSVC而非SVC(kernel='linear')处理高维稀疏数据,因其更快、更稳、可解释;RBF核仅在低维/中维且边界明显非线性时才值得调参,且必须标准化后手动设gamma。 线性核(kernel='linear')在高维稀疏数据或样本量远大于特征数时,往往比RBF更快、更稳、更可解释;RBF核(kernel='rbf')只在低维/中维且边界明显非线性时才值得投入调参成本——...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3428073/"><h6>Python类中的__str__和__repr__如何选择_实现易读的对象调试信息输出</h6></a>
    		<div class="data"><span class="month">05月</span><span class="day">26</span><span class="year">2026</span></div>
            <div class="news-info">
            <p>该用__str__时用于面向用户的易读字符串表示(如print(obj)),必须写__repr__时用于开发者调试,需包含关键字段且格式稳定;优先实现__repr__,它缺失时无fallback,而__str__缺失会自动调用__repr__。 什么时候该用__str__,什么时候必须写__repr__ __str__是给人看的,__repr__是给开发者/解释器看的。打印对象时(比如print(...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3427869/"><h6>Python怎么在PyTorch DDP中正确保存模型_判定rank0主进程与多节点文件合并</h6></a>
    		<div class="data"><span class="month">05月</span><span class="day">24</span><span class="year">2026</span></div>
            <div class="news-info">
            <p>准确判断DDP中rank0主进程需先检查torch.distributed.is_initialized()为True,再调用torch.distributed.get_rank()==0;单卡调试时可默认rank0,但生产环境必须显式初始化且在模型封装前完成。 如何准确判断DDP中的rank0主进程 DDP(DistributedDataParallel)下,torch.distributed....</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3427563/"><h6>CSS怎么注释内容_CSS代码注释方法与规范教程</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">28</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>CSS注释使用//包裹,用于解释代码意图、禁用样式或标记待办事项,提升代码可读性与维护性,是团队协作和自我回顾的重要工具。 CSS中注释内容非常直接,你只需要使用/*...*/这种多行注释格式。它允许你在代码中插入解释性文本,这些文本会被浏览器完全忽略,不会影响页面的渲染或性能。 解决方案 在CSS中,无论你想注释单行还是多行,都统一使用/*和*/来包裹你的注释内容。这种方式非常灵活,可以用于解释...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3427001/"><h6>为什么需要在线运行PHP代码?如何选择合适的在线运行平台?</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">27</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>在线运行PHP代码的最大好处是省去本地环境搭建,适合快速测试、学习、分享和协作。它提供即时反馈,降低学习门槛,方便远程调试与教学,但无法完全替代本地开发环境。选择平台时需关注PHP版本、扩展支持、多文件处理、数据库集成、性能及安全性。在线工具是本地开发的有力补充,适用于轻量级任务,提升效率与协作体验。 在线运行PHP代码,在我看来,最直接的好处就是省去了本地环境搭建的繁琐与耗时。无论是为了快速测试...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3426501/"><h6>什么是PHP在线IDE?如何选择适合自己的在线开发环境?</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">26</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>PHP在线IDE核心优势是即开即用、环境标准化与跨设备协作,省去本地配置麻烦,适合快速开发与团队协同;局限在于依赖网络、资源受限及底层控制力弱。选择时应关注代码编辑、调试、终端、Git集成与环境自定义能力,根据项目规模与团队需求权衡免费或企业级方案。 PHP在线IDE,简单来说,就是让你能直接在浏览器里写PHP代码、运行项目,甚至进行调试的开发环境。它把传统上需要在本地电脑上安装配置的各种工具——...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3426315/"><h6>Neo4j查询结果转换为D3兼容的图JSON格式(节点与链接)教程</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">25</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>本文旨在指导开发者如何将Neo4j数据库的查询结果转换为D3等前端可视化库所需的图JSON格式(包含独立的节点和链接列表)。我们将探讨使用Neo4j的APOC插件及其apoc.export.json.data过程,结合Node.js的neo4j-driver,实现高效且结构化的数据转换,从而简化前端图谱渲染的流程。1.理解Neo4j驱动程序输出与可视化需求 在使用node.js的neo4j-dri...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3425542/"><h6>如何选择适合自己的耳塞套尺寸?</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">24</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>合适的耳塞套应舒适、密封且稳固。通过佩戴舒适度、低音表现和运动时的稳定性判断尺寸是否合适,左右耳可能需不同尺寸。硅胶套耐用易清洁,适合运动;海绵套舒适隔音好但寿命短,需定期更换。一般硅胶套每3-6个月更换,海绵套每1-3个月更换,出现破损或异味应立即更换。 选择合适的耳塞套尺寸,关键在于舒适度和密封性。太小会漏音,太大则会胀痛。尝试不同尺寸,找到那个既能稳固佩戴,又能让你几乎忘记它存在的那个。 选...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3425531/"><h6>Golang开发IDE如何选择 对比VSCode与Goland配置技巧</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">24</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>VSCode轻量灵活,适合多语言和自定义配置;Goland功能深度集成,提升大型项目开发效率。选择取决于项目规模、团队协作、个人偏好与成本考量。 在Go语言的开发环境中,IDE的选择常常是开发者津津乐道的话题。究竟是追求轻量与极致自定义的VSCode,还是倾向于开箱即用、深度集成的Goland?这没有一个标准答案,更多的是一种个人偏好与项目需求的权衡。简单来说,VSCode以其灵活的插件生态和资源...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3425378/"><h6>XSLT如何对节点进行分组操作?</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">24</span><span class="year">2025</span></div>
            <div class="news-info">
            <p>XSLT分组主要有两种方式:XSLT2.0+使用for-each-group指令,通过group-by等属性实现直观高效的分组;XSLT1.0则依赖MuenchianGrouping,利用key()和generate-id()筛选每组首个节点,虽复杂但有效。 XSLT对节点进行分组操作,核心上来说,主要有两种主流方式:对于XSLT2.0及更高版本,我们有强大的for-each-group指令,它极...</p>
    		</div>
    	</div>
    </li>
            <li class="listloop"> 
    	<div class="news-tit news-right">
    		<a href="https://www.vycc.cn/tutorial/3425003/"><h6>XSLT如何生成注释和处理指令?</h6></a>
    		<div class="data"><span class="month">08月</span><span class="day">22</span><span class="year">2025</span></div>
            <div class="news-info">
            <p><blockquote>使用和可在XSLT输出中添加注释和处理指令,前者生成格式的注释以提升可读性、调试性,后者生成形式的指令以传递应用程序特定信息;二者均支持静态与动态内容结合,常用于嵌入元数据、样式表链接或系统状态,但需避免注释中出现--、确保PI目标名合法,并注意内容编码与信息冗余问题,最佳实践包括精简内容、封装模板、验证输出及防范敏感信息泄露。</blockquote&g...</p>
    		</div>
    	</div>
    </li>
            
    </ul>				
    </div>
    <div class="sidebar" id="sidebar">
    <div class="searchform">
    <form method="get" id="searchform" action="https://www.baidu.com/baidu"  target="_blank">
    <input type="search" name="word" value="" id="s" placeholder="搜索..." />
    <input name=tn type=hidden value="bds">
    <input name=cl type=hidden value="3">
    <input name=ct type=hidden value="2097152">
    <input name=si type=hidden value="vycc.cn">
    <button id="searchsubmit"><i class="fa fa-search"></i></button>
    </form>
    </div>
    <div class="right-content" id="divComments">
    <h3 class="sidebar_title">热门推荐</h3>
    <ul>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489893/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img131.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱牧师全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489893/" title="炉石传说逃离紫罗兰监狱牧师全卡一览">炉石传说逃离紫罗兰监狱牧师全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>198398</span>
            </li>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489892/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img262.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱盗贼全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489892/" title="炉石传说逃离紫罗兰监狱盗贼全卡一览">炉石传说逃离紫罗兰监狱盗贼全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>174367</span>
            </li>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489891/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img400.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱战士全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489891/" title="炉石传说逃离紫罗兰监狱战士全卡一览">炉石传说逃离紫罗兰监狱战士全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>266636</span>
            </li>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489890/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img48.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱术士全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489890/" title="炉石传说逃离紫罗兰监狱术士全卡一览">炉石传说逃离紫罗兰监狱术士全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>111394</span>
            </li>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489889/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img345.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱中立全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489889/" title="炉石传说逃离紫罗兰监狱中立全卡一览">炉石传说逃离紫罗兰监狱中立全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>195819</span>
            </li>
        <li><span class="sideimg">
            <a href="https://www.vycc.cn/gonglve/3489888/">
                <img decoding="async" src="https://www.vycc.cn/file/thumb/img296.jpg/180-125.jpg" alt="炉石传说逃离紫罗兰监狱猎人全卡一览">
            </a>
            </span>
            <p><a href="https://www.vycc.cn/gonglve/3489888/" title="炉石传说逃离紫罗兰监狱猎人全卡一览">炉石传说逃离紫罗兰监狱猎人全卡一览</a></p>
            <span><i class="fa fa-clock-o"/></i>2026-07-13<i class="fa fa-eye fa-fw"></i>42418</span>
            </li>
    </ul>
    </div>
    <div class="right-content" id="sidead">
        <div class="_ap6nuhq2rf"></div>
        <script type="text/javascript"> 
            (window.slotbydup = window.slotbydup || []).push({
                id: "u6703708",
                container: "_ap6nuhq2rf",
                async: true
            });
        </script>
    </div>
    <div class="footer-news">
    <div class="links">友情链接:<a href="https://www.allimg.cn/" target="_blank">全图网</a>
            <a href="https://www.jjatech.com/" target="_blank">可视对讲</a>
            <a href="https://www.vszh.cn/" target="_blank">启程网</a>
            <a href="https://www.096x.com/" target="_blank">核游网</a>
            <a href="https://www.biniku.com/" target="_blank">比你酷</a>
            <a href="https://www.sztg.com.cn/" target="_blank">深圳推广</a>
            <a href="https://www.syai.cn/" target="_blank">视野AI</a>
            <a href="https://www.vycc.cn" target="_blank">非常游戏网</a>
            <a href="https://www.myinqi.com/" target="_blank">骃骐网</a>
            </div>  
    	<p><i class="fa fa-copyright fa-fw"></i>2026. <a href="/">非常游戏网</a> 手机 网络游戏攻略大全!</p>
    	<p class="cang"><a rel="nofollow" target="_blank" href="https://beian.miit.gov.cn/">粤ICP备2020108910号</a>  <a rel="nofollow" target="_blank" href="#">流量统计</a></p>	
    </div>
    </div>	
    </div>
    <a class="scroll-top" style="display: none;"><i class="fa fa-angle-double-up" aria-hidden="true"></i></a>
    <script src="/tutorial/file/css/all.js"></script>
    <script src="/tutorial/file/css/jquery.lazyload.js"></script> 
    <script src="/tutorial/file/css/tongji.js"></script>
    <script type="text/javascript">
    $("img").lazyload({ 
        placeholder: "/tutorial/file/css/grey.gif", 
        effect : "fadeIn" 
    });
    </script> 
    <script>
        (function(c,l,a,r,i,t,y){
            c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
            t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i+"?ref=bwt";
            y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
        })(window, document, "clarity", "script", "uww484mxvd");
    </script>
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "Article",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.vycc.cn/tutorial/3422298/"
      },
      "headline": "XPath的comment()如何选择注释节点?",
      "image": [
        "https://www.vycc.cn/tutorial/file/thumb/25.jpg"
      ],
      "datePublished": "2025-08-17T06:38:51+08:00",
      "dateModified": "2025-08-17T06:38:51+08:00",
      "publisher": {
        "@type": "Organization",
        "name": "非常游戏网",
        "logo": {
          "@type": "ImageObject",
          "url": "https://www.vycc.cn/file/logo.png"
        }
      },
      "description": "答案:XPath中comment()函数用于选择注释节点,与text()不同,前者提取内的内容,后者获取元素内的文本;可通过//comment()获取所有注释,或结合轴、谓词和字符串函数精确筛选目标注释。 XPath中,comment()函数专门用来选择文档中的注释节点。它就像一个过滤器,只把那些被..."
    }
    </script>
    </body>
    </html>