Add one element to the parent element with xslt without copying

pauloricardo

New Member
I want to add an element to source xml.Example:Source\[code\]<?xml version="1.0" encoding="UTF-8" standalone="no"?> <DataArea> <PurchaseOrder> <PurchaseOrderLine> <DocumentReference type="customersReference1"> <DocumentID> <ID>23423</ID> </DocumentID> </DocumentReference> <Item> <CustomerItemID> <!-- ArtNr --> <ID>444</ID> </CustomerItemID> </Item> <Quantity unitCode="PCE">17.3</Quantity> </PurchaseOrderLine> </PurchaseOrder> </DataArea>\[/code\]I want to add element\[code\]<LineNumber>10</LineNumber>\[/code\]to \[quote\] DataArea/PurchaseOrder/PurchaseOrderLine/\[/quote\]So first solution will be copying all data from original xml and then \[code\]LineNumber\[/code\] like\[code\]<xsl:copy> <xsl:apply-templates select="DocumentReference"/> <xsl:apply-templates select="Item"/> <xsl:apply-templates select="Quantity"/> <!-- ADD HERE LINENUMBER --></xsl:copy>\[/code\]How can I add \[code\]LineNumber\[/code\] without manually copying all elements?
 
Back
Top