登录
首页 >  Golang >  Go问答

截取 XML 字符串中第一个":"之后的所有字符

来源:stackoverflow

时间:2024-02-26 22:21:23 233浏览 收藏

偷偷努力,悄无声息地变强,然后惊艳所有人!哈哈,小伙伴们又来学习啦~今天我将给大家介绍《截取 XML 字符串中第一个":"之后的所有字符》,这篇文章主要会讲到等等知识点,不知道大家对其都有多少了解,下面我们就一起来看一吧!当然,非常希望大家能多多评论,给出合理的建议,我们一起学习,一起进步!

问题内容

<b:queues i:nil="true"/>
 <b:receivedfrom>vj</b:receivedfrom>
 <b:specialgdsname i:nil="true"/>

我想删除“:”之前的所有数据,包括“:”

我想做这样的:

<Queues i:nil="true"/>
 <ReceivedFrom>VJ</b:ReceivedFrom>
 <SpecialGDSName i:nil="true"/>

正确答案


像这样运行 XML through an XSLT,这将删除与这些元素关联的命名空间:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output indent="yes"/>
        
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
      <xsl:element name="{local-name()}">
          <xsl:apply-templates select="@*|node()"/>
      </xsl:element>
  </xsl:template>
    
</xsl:stylesheet>

您可以使用仅匹配那些 b:* 元素的更专门的模板,并对模板执行相同的操作以从属性中剥离名称空间。

理论要掌握,实操不能落!以上关于《截取 XML 字符串中第一个":"之后的所有字符》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>