1
我正在解析一个XMl文件并使用内容在Java中使用XPath处理数据设置,可能会出现这样的情况:我们可以将空标记作为应该处理的输入。节点对象 - 为空节点对象分配值
但是当我试图为空节点对象与setNodeValue和setTextContent方法仍然得到同样的问题设定值。我们有没有其他选项可以为空节点对象设置值。
**//Code Snippet:**
Node title = XPathAPI.selectSingleNode("Input Node", "title/text()");
// *Here if there is no input title tag, then the title variable would be null*
title.setNodeValue("Value to set on the null node");