简体   繁体   中英

How to use an XSLT to move data between XML nodes

I don't know a lot about xslt but I need to fix a bug in someone else's code. The issue is that some data is not being outputted correctly in an XML file so I need to use an XSLT to move the data to the correct node. An example is shown below:

Incorrect XML:

<record name="recordname" value="Text(AAxxxx)">
<field name="recordID" value=""/>
</record>

Correct XML:

<record name="recordname" value="Text(AAxxxx)">
    <field name="recordID" value="Text(AAxxxx)"/> 
    </record>

So I need to copy the value of the value field from the record name node to value in the field name node. Can anyone help me with this?

Thanks in advance

Extract "value" in XSLT is:

<xsl:value-of select="record/field/@value" />

Extract atribbute is "@" after of element.

this is a possibility.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM