开发者

How to add new attributes to a tag in XML file using XSLT? [duplicate]

开发者 https://www.devze.com 2023-04-05 01:49 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: Add an attribute with static value with xslt
This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

Add an attribute with static value with xslt

I have an XML file which I need to modify.

For example:

Say my XML has a form tag

<FORM name=""></FORM>

Now say I want to put some extra info to this tag like

frame="frmName" frameby="name"

Expected result of running batch file OR some XSLT

<FORM name="" frame=开发者_如何学编程"frmName" frameby="name" ></FORM>

How can I do it using batch file?

I am just a beginner so please try to be simple.

Thank you all


Have you considered using XSLT to modify the XML, as further explained here

EDIT

xlst solution

<xsl:template match="FORM">
 <xsl:copy>
   <xsl:attribute name="name">frmName</xsl:attribute>
   <xsl:apply-templates select="node()|@*/>
  </xsl:copy>
 </xsl:template>
0

精彩评论

暂无评论...
验证码 换一张
取 消