【发布时间】:2016-01-18 15:21:35
【问题描述】:
想象一下这个 XML:
<DocumentElement>
<PropsAndValues>
<Name># CONFIGURATION_NODE # DO NOT DELETE THIS ROW #</Name>
<Keywords>#</Keywords>
<Tests>#</Tests>
<Type>#</Type>
</PropsAndValues>
<PropsAndValues>
<Name>PersonSuiteTC-1</Name>
<Keywords/>
<Tests>Definition:"Business Process":PersonSuiteTC-1</Tests>
<Type>HIGH</Type>
</PropsAndValues>
<PropsAndValues>
<Name>No Operation</Name>
<Keywords/>
<Tests/>
<Type>TECH</Type>
</PropsAndValues>
<PropsAndValues>
<Name>Start</Name>
<Keywords>No Operation</Keywords>
<Tests/>
<Type>LOW</Type>
</PropsAndValues>
<PropsAndValues>
<Name>Open Application</Name>
<Keywords>No Operation</Keywords>
<Tests/>
<Type>LOW</Type>
</PropsAndValues>
<PropsAndValues>
<Name>Go To Profile Finder</Name>
<Keywords>No Operation</Keywords>
<Tests/>
<Type>LOW</Type>
</PropsAndValues>
<PropsAndValues>
<Name>Search Person</Name>
<Keywords>No Operation</Keywords>
<Tests/>
<Type>LOW</Type>
</PropsAndValues>
<PropsAndValues>
<Name>End</Name>
<Keywords>No Operation</Keywords>
<Tests/>
<Type>LOW</Type>
</PropsAndValues>
<PropsAndValues>
<Name>PersonSuiteTC-1</Name>
<Keywords>
Start Open Application Go To Profile Finder Search Person End
</Keywords>
<Tests/>
<Type>HIGH</Type>
</PropsAndValues>
</DocumentElement>
我需要用这个头创建一个方法:
private static void addRelation(String kWName, String elemName) throws Exception {
}
将elemName 添加到具有<Name> 标签值kwName 的节点的标签<Keywords>。
例如:
addRelation("PersonSuiteTC-1", "Add this String to <Keywords> tag"),应该转到名称为“PersonSuiteTC-1”的节点,并将“将此字符串添加到标签”添加到<Keywords> 标签。
最简单的方法是什么?
谢谢。
【问题讨论】:
-
要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是无关紧要的,因为它们往往会吸引固执己见的答案和垃圾邮件。相反,请描述问题以及迄今为止为解决该问题所做的工作。
标签: java xml xpath methods tags