关于如何将带有换行符的单元格文本从电子表格转换为 XML 的见解
因此,
我尝试从 ODS 电子表格中的单元格获取内容。
我正在做类似的事情:
<xsl:value-of select="./table:table-cell[6]/text:p/text()" disable-output-escaping="yes"/>
令人讨厌的一点是我的表格单元格的内容有很多换行符,并且我的代码无法获取全文=/
我也尝试了上面代码的许多变体,但没有成功。有人可以给我建议吗?
谢谢^^
So,
I'm trying to get the content from a cell in an ODS spreadsheet.
I'm doing something like:
<xsl:value-of select="./table:table-cell[6]/text:p/text()" disable-output-escaping="yes"/>
The nasty point is that the content of my table-cell have many line breaks and my code can't get to the full text =/
I also tried many variations from the code above but without a success. Can someone give me an advice?
Thanks ^^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定为什么换行符会成为问题,除非您的意思不是文字换行符(即
字符),而是类似于
的某种段落元素HTML 中的
。如果是后者,那么这可能可以解释问题,因为您的 XPath 表达式不会返回元素的文本内容。它返回该元素的直接子元素的所有文本节点。如果您只需要纯文本内容(即所有后代文本节点,无论多深),请删除 XPath 末尾的
/text()
。我根本不明白您的示例中
disable-output-escaping
的意义是什么。请澄清为什么您认为那里需要它。I'm not sure why line breaks would be a problem, unless by that you mean not literal line breaks (i.e.
characters), but some kind of paragraph element similar to
<p>
in HTML. If it's the latter, than that might explain things, since your XPath expression does not return the text content of the element. It returns all text nodes that are immediate children of the element. If you just need the plain text content (i.e. all descendant text nodes, no matter how deep), remove/text()
at the end of your XPath.I do not understand what is the point of
disable-output-escaping
in your example at all. Please clarify why you think it's needed there.