Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这一行:
//div[@id="transactions"]/p
给出这个输出(来自我试图获取的 html 内容):
我怎样才能使这个查询返回一个这样的字符串(如果每个都<p>在它自己的行中的内容):
<p>
contentOfP1 contentOfP2 contentOfP3 ...
请注意,每个 p 都有子节点 (<strong>和<a>) 和没有标签的文本。当尝试从特定的 检索所有文本时<p>,它给出了:
<strong>
<a>
使用:
//div[@id="transactions"]/p/concat(string(.), '
')
或者,如果需要空间标准化的“每个段落的内容”——如注释中所示,请使用:
//div[@id="transactions"]/p/concat(normalize-space(.), '
')