Below is the actual xml:
<?xml version="1.0" encoding="utf-8"?>
<employee>
<Name>ABC</Name>
<Dept>CS</Dept>
<Designation>sse</Designation>
</employee>
And i want the output as below:
<?xml version="1.0" encoding="utf-8"?>
<employee>
<Name>ABC</Name>
<Age>34</Age>
<Dept>CS</Dept>
<Domain>Insurance</Domain>
<Designation>sse</Designation>
</employee>
Is this possible to add XML element in between using xslt?
Please give me sample!
Here is an XSLT 1.0 stylesheet that will do what you asked:
Obviously the logic will vary depending on where you will be getting the new data from, and where it needs to go. The above stylesheet merely inserts an
<Age>element after every<Name>element, and a<Domain>element after every<Dept>element.(Limitation: if your document could have
<Name>or<Dept>elements within other<Name>or<Dept>elements, only the outermost ones will have this special processing. I don’t think you intend for your document to have this kind of recursive structure, so it wouldn’t affect you, but it’s worth mentioning just in case.)