Is there a way to detect the backslash in the empty element in order to not return it?
如果您真正想要的是位置标记内的文本,则可以使用正确的 XPath 轻松找到这些文本:
doc.search('//location/text()')
如果出于某种原因,您实际上需要位置元素本身,请使用以下命令:
doc.search('//location/text()/..')
If what you really want is the text inside location tags, you can find those easily with the right XPath:
If, for some reason, you actually need the location element itself, use this:
在语义上与 相同,因此应如此对待。要查找所有空标签,只需跳过没有任何子节点(包括文本)的元素。
<location/> is semantically identical to <location></location>, and should be treated as such. To find all empty tags, just skip elements which do not have any child nodes (including text).
<location/>
<location></location>
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
如果您真正想要的是位置标记内的文本,则可以使用正确的 XPath 轻松找到这些文本:
如果出于某种原因,您实际上需要位置元素本身,请使用以下命令:
If what you really want is the text inside location tags, you can find those easily with the right XPath:
If, for some reason, you actually need the location element itself, use this:
在语义上与
相同,因此应如此对待。要查找所有空标签,只需跳过没有任何子节点(包括文本)的元素。<location/>
is semantically identical to<location></location>
, and should be treated as such. To find all empty tags, just skip elements which do not have any child nodes (including text).