关于如何将带有换行符的单元格文本从电子表格转换为 XML 的见解

发布于 2024-08-02 05:56:59 字数 285 浏览 2 评论 0原文

因此,

我尝试从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱要勇敢去追 2024-08-09 05:56:59

我不确定为什么换行符会成为问题,除非您的意思不是文字换行符(即 字符),而是类似于 的某种段落元素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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文