on 01-13-2014 9:21 AM
Hi All,
I am having the following xml . I need to remove one field from the payload rest of the structure needs to be same.
Input
<Parent>
<Child1>
<Field1></Field1>
<Field2></Field2>
</Child1>
<Child2>
<Field3></Field3>
<Field4></Field4>
</Child2>
<Child3>
<Field5></Field5>
<Field6></Field6>
<Item1>
<Field7></Field7>
</Item1>
<Item2>
<Field8></Field8>
<Field9></Field9>
</Item2>
<Item3>
<Field10></Field10>
</Item3>
</Child3>
</Parent>
In the above XML i need to remove "<Field9>". So my output should be as below
OutPut
<Parent>
<Child1>
<Field1></Field1>
<Field2></Field2>
</Child1>
<Child2>
<Field3></Field3>
<Field4></Field4>
</Child2>
<Child3>
<Field5></Field5>
<Field6></Field6>
<Item1>
<Field7></Field7>
</Item1>
<Item2>
<Field8></Field8>
</Item2>
<Item3>
<Field10></Field10>
</Item3>
</Child3>
</Parent>
Kindly let me know how can we do it using XSLT mapping.
Thanks,
Sudha
Hi Sudharee,
With your XML, if you try with this XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Field9"/>
</xsl:stylesheet>
You will get this:
<Parent>
<Child1>
<Field1/>
<Field2/>
</Child1>
<Child2>
<Field3/>
<Field4/>
</Child2>
<Child3>
<Field5/>
<Field6/>
<Item1>
<Field7/>
</Item1>
<Item2>
<Field8/>
</Item2>
<Item3>
<Field10/>
</Item3>
</Child3>
</Parent>
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Iñaki Vila,
Thanks for the reply.
But i am having prefix for the field as given in below xml. Can you pls let me know how to handle the same. I tried replacing Field9 with ns0:Field9 in above code but it did not work.
Input
<ns0:Parent xmlns:ns0="http://abc/def">
<Child1>
<Field1></Field1>
<Field2></Field2>
</Child1>
<Child2>
<Field3></Field3>
<Field4></Field4>
</Child2>
<ns0:Child3>
<ns0:Field5></ns0:Field5>
<ns0:Field6></ns0:Field6>
<ns0:Item1>
<ns0:Field7></ns0:Field7>
</ns0:Item1>
<ns0:Item2>
<ns0:Field8></ns0:Field8>
<ns0:Field9></ns0:Field9>
</ns0:Item2>
<ns0:Item3>
<ns0:Field10></ns0:Field10>
</ns0:Item3>
</ns0:Child3>
</ns0:Parent>
Thanks in Advance
Sudha
Replace these two lines:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> and
<xsl:template match="Field9"/>
with
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://abc/def"> and
<xsl:template match="ns0:Field9"/> respectively.
Hello,
Chk this:
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.