我有一个像=
的XML<?xml version="1.0" encoding="utf-8" ?>
<UserRecord xmlns="http://www.company.com/api/user/2015/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code1>(MC)MyCompany United Kingdom</Code1>
<Code2>(MC)United Kingdom</Code2>
<Organization1>(90)R&D</Organization1>
<Organization2>(1905)R&D</Organization2>
<Organization3>(903)Roadmap Dev</Organization3>
</UserRecord>
我试图在()括号之间提取数据并尝试以这种格式获取XML =
<?xml version="1.0" encoding="utf-8" ?>
<UserRecord xmlns="http://www.company.com/api/user/2015/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code1>MC</Code1>
<Code2>MC</Code2>
<Organization1>90</Organization1>
<Organization2>1905</Organization2>
<Organization3>903</Organization3>
</UserRecord>
我尝试使用“substring-before(substring-after(”)但我无法真正理解这一点,并对如何正确的语法感到困惑。
你能帮帮我吗?谢谢
答案 0 :(得分:2)
如果您使用
<xsl:template match="*[not(*) and contains(., '(') and contains(., ')')]">
<xsl:copy>
<xsl:value-of select="substring-before(substring-after(., '('), ')')"/>
</xsl:copy>
</xsl:template>
更改元素和
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
复制其余部分,然后初始表达式substring-before(substring-after(
应该这样做。