小编use*_*825的帖子

使用xpath删除不可破坏的空格

我有以下xml文档:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
<child1>&#160;Well, some  spaces and nbsps  &#160;</child1>
<child2>&#160; some more                  &#160;  or whatever          </child2>
<child3>         a nice text</child3>
<child4>how                              to get rid of all the nasty spaces&#160;          ?                                  </child4>
</data>
</root>
Run Code Online (Sandbox Code Playgroud)

我必须删除所有不可破坏的空格,连接文本并将其正常化.

我的xpath查询(它适用于连接和规范化 - 我已将替换为'x'仅用于测试目的):

normalize-space(replace(string-join(//data/*,' '),'&#160;','x'))
Run Code Online (Sandbox Code Playgroud)

我的问题:我找不到"&#160;"-whitespace来替换它.

期待您的回答,

xml xpath

5
推荐指数
1
解决办法
6211
查看次数

如何在xslt输出的末尾添加换行符?

可能重复:
在XSLT中生成新行

如果有以下xslt文件:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="text" />
    <xsl:template match="//teilnehmer">
        <xsl:value-of select="name"/>
        <xsl:value-of select="kind"/>
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

转换后的输出是一个没有任何空格或换行符的字符串

如何添加一些格式(例如名称后的换行符)?

提前致谢!

xml xslt

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

xml ×2

xpath ×1

xslt ×1