简体   繁体   English

使用DOM解析器在xml Java中使用子节点搜索特定节点

[英]Search for a particular node using child node in xml java using DOM parser

I have the following XML structure 我有以下XML结构

<CodeSnippet>
  <Code>
        <Tag></Tag> 
        <Title></Title>  
        <Snippet></Snippet>
 </Code>

I would like to search for specific node based on "Title" and update the "Snippet" value of that node. 我想根据“标题”搜索特定的节点,并更新该节点的“片段”值。

The XPath i have used is "/Code[Title/text()='" + getTitle + "']". 我使用的XPath是“ / Code [Title / text()='” + getTitle +“']”。 But, i am unable to get the Title node. 但是,我无法获得“标题”节点。 Someone, please correct my xpath i am using. 有人,请更正我正在使用的xpath。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM