|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
To remove duplicate fields from Message |
« View previous topic :: View next topic » |
Author |
Message
|
mukeshkumar234 |
Posted: Thu Oct 08, 2015 12:15 am Post subject: To remove duplicate fields from Message |
|
|
 Newbie
Joined: 13 Sep 2015 Posts: 6
|
Hi,
I am using IIB 10, and i have XML message as
Code: |
<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/">
<NS1:Body>
<NS2:getCustomerResponse xmlns:NS2="http://yh.com/tr">
<response>
<party>
<customer>
<name>
<NameId>1502877</NameId>
<Name>Selmiye As</Name>
</name>
<name>
<NameId>1502877</NameId>
<Name>Selmiye As</Name>
</name>
<name>
<NameId>1502878</NameId>
<Name>Lokma Cafe</Name>
</name>
<name>
<NameId>1502878</NameId>
<Name>Lokma Cafe</Name>
</name>
<address>
<AddressId>536052</AddressId>
<AddressLine1>SOĞANYEMEZ MH FARUK SERPİL PARK NO:1</AddressLine1>
<AddressLine2/>
<State_or_Province/>
<County_or_Sub-District>-</County_or_Sub-District>
<District/>
<Zip_Code/>
<Latitude/>
<Longitude/>
<GLN/>
<AddressKey/>
<Geo/>
<AddressType/>
<NS2:LanguageKey>TR</NS2:LanguageKey>
</address>
<address>
<AddressId>536053</AddressId>
<AddressLine1>SOĞANYEMEZ MH FARUK SERPİL PARK NO:1</AddressLine1>
<AddressLine2/>
<State_or_Province/>
<County_or_Sub-District>-</County_or_Sub-District>
<District/>
<Zip_Code/>
<Latitude/>
<Longitude/>
<GLN/>
<AddressKey/>
<Geo/>
<AddressType/>
<NS2:LanguageKey>TR</NS2:LanguageKey>
</address>
<address>
<AddressId>536052</AddressId>
<AddressLine1>SOĞANYEMEZ MH FARUK SERPİL PARK NO:1</AddressLine1>
<AddressLine2/>
<State_or_Province/>
<County_or_Sub-District>-</County_or_Sub-District>
<District/>
<Zip_Code/>
<Latitude/>
<Longitude/>
<GLN/>
<AddressKey/>
<Geo/>
<AddressType/>
<NS2:LanguageKey>TR</NS2:LanguageKey>
</address>
<address>
<AddressId>536053</AddressId>
<AddressLine1>SOĞANYEMEZ MH FARUK SERPİL PARK NO:1</AddressLine1>
<AddressLine2/>
<State_or_Province/>
<County_or_Sub-District>-</County_or_Sub-District>
<District/>
<Zip_Code/>
<Latitude/>
<Longitude/>
<GLN/>
<AddressKey/>
<Geo/>
<AddressType/>
<NS2:LanguageKey>TR</NS2:LanguageKey>
</address>
</customer>
</party>
</response>
</NS2:getCustomerResponse>
</NS1:Body>
</NS1:Envelope> |
I want to remove the duplicate fields from the xml message.
I have tried while loop but not able to achive it. Can anyone help me in this.  _________________ Be Happy
@Mukesh |
|
Back to top |
|
 |
timber |
Posted: Thu Oct 08, 2015 4:19 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Two recommendations:
1. Define (carefully) what you mean by 'duplicate fields'
2. Tell us what you tried. Otherwise we end up telling you to do stuff that you already know. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 08, 2015 4:23 am Post subject: Re: To remove duplicate fields from Message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mukeshkumar234 wrote: |
I want to remove the duplicate fields from the xml message. |
By "duplicate fields" do you mean each "address" stanza where "AddressId" is the same as a previous occurrence, or do you mean that you want to remove each "AddressLine1" that has the same value as a previous occurrence?
mukeshkumar234 wrote: |
I have tried while loop but not able to achive it. |
Why not? What happened? Wrong result? Stack dump? Flying monkeys came out of the back of the computer asking if you'd seen a girl in a blue gingham dress with a small dog?
On the face of it, some kind of loop (such as the while you describe) would seem to be the correct design solution. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Oct 08, 2015 5:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Your loop will look one way if you have a guarantee that all AddressId fields are in a sorted order - i.e. that the duplicates are all adjacent to each other (before or after).
Your loop will have to look entirely differently if they are not adjacent to each other.
While this is a broker specific implementation, the problem itself is "how do I remove duplicates from a list", and the solutions possible for that are pretty much universal to all programming languages. (some provide you standard functions that do it) _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|