Link to home
Start Free TrialLog in
Avatar of tesmc
tesmcFlag for United States of America

asked on

XSL: how to copy entire node but replace contents of one given element?

I want to copy over all instances of an xml input but replace the contents (by substring) of one of the elements <Iden> with digital value only.

<Bill>
	<FOP>
		<Iden>R2</Iden>
		<CreditCard>
			<CCCode>DC</CCCode>
			<CCNum>1212301</CCNum>
			<CCExp>
				<Month>2</Month>
				<Year>12</Year>
			</CCExp>
			<Fname>JOHN</Fname>
			<Lname>SMITH</Lname>
		</CreditCard>
	</FOP>
	<Addr Use="T">
		<Iden>R1</Iden>
		<Street>720 W 10 ST</Street>
	</Addr>
</Bill>

Open in new window


will become
<Bill>
	<FOP>
		<Iden>2</Iden>
		<CreditCard>
			<CCCode>DC</CCCode>
			<CCNum>1212301</CCNum>
			<CCExp>
				<Month>2</Month>
				<Year>12</Year>
			</CCExp>
			<Fname>JOHN</Fname>
			<Lname>SMITH</Lname>
		</CreditCard>
	</FOP>
	<Addr Use="T">
		<Iden>1</Iden>
		<Street>720 W 10 ST</Street>
	</Addr>
</Bill>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tesmc

ASKER

thank you both. i went with @mccarl approach.
No worries, glad to help!  :)