on 08-23-2016 3:51 PM
I have requirement to replace invalid xml characters in xml body text.
& with &
< with >
> with <
" with "
' with '
for eg: <SizeCode>white <> black & green ' "</SizeCode>
Current result:
<SizeCode>white >< black & green ' "</SizeCode<
Expected result:
<SizeCode>white >< black & green ' "</SizeCode>
I am using below java mapping, But It's replacing XML tags as well.
Please help me to correct this Java code or Provide me some working code
Thanks,
Tanuja
When you replace all < and > in the whole XML, you also replace regular tag delimiters and make your XML corrupt. As your incoming XML is not valid, I would recommend that the issue would be fixed at the sender side. The sender must provide valid XML.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anupam,
We have removed CDATA before this java mapping. It's failing at receiver end due to this special characters.
I have issue with only this field <MessageText>Special characters Test &apos; &apos; # ~ + = </MessageText> .
<?xml version="1.0" encoding="UTF-8"?>
<test>
<content>
<data>
<Deliveries>
<Delivery>
<DeliveryHeader>
<ShipToParty>
<Title>Mr</Title>
<FirstName>er</FirstName>
<LastName>sdghfd</LastName>
<AddressLine1>51 BERTRAM ROAD</AddressLine1>
<AddressLine2/>
<AddressLine3/>
<AddressLine4/>
<AddressLine5/>
<AddressLine6/>
<City>ENFIELD</City>
<PostCode>en11lr</PostCode>
<County>MIDDX</County>
<CountryName>United Kingdom</CountryName>
<Country>GB</Country>
<Email>abc@test.com</Email>
<PartyID/>
<PhoneNumber>+457456754</PhoneNumber>
</ShipToParty>
<DeliveryDate>2016-08-27T00:00:00+01:00</DeliveryDate>
<DeliveryMethod>Saturday</DeliveryMethod>
<DeliveryOption>SA</DeliveryOption>
<DeliveryOptionDescription>Saturday</DeliveryOptionDescription>
<DeliveryNumber>0</DeliveryNumber>
<DeliveryCharge>15.95</DeliveryCharge>
<Messages>
<Message>
<MessageType>GIFT</MessageType>
<MessageText>Special characters Test &apos; &apos; # ~ + = </MessageText>
</Message>
</Messages>
</DeliveryHeader>
<OrderLines>
<OrderLine>
<OrderLineNumber/>
<OrderLineType>GM</OrderLineType>
<ItemID>000000000004126152</ItemID>
<Charges>
<Charge>
<ChargeID>Shipping_Charge</ChargeID>
<Description>Shipping</Description>
<Amount>15.95</Amount>
<ChargePerUnit>0.00</ChargePerUnit>
<IsDiscount>N</IsDiscount>
<isBillable>Y</isBillable>
</Charge>
</Charges>
<Taxes>
<Tax>
<TaxID>Sales_Tax</TaxID>
<Description>Sales_Tax</Description>
<Amount>7.66000</Amount>
</Tax>
<Tax>
<TaxID>Shipping_Tax</TaxID>
<Description>Shipping_Tax</Description>
<Amount>2.66000</Amount>
</Tax>
</Taxes>
<SizeCode>NONE</SizeCode>
<Colour>No Colour</Colour>
<Brand>Cochine</Brand>
<ItemDescription>CC CANDLE JUNIPER & GINGER XMAS 3</ItemDescription>
<LongDescription/>
<ShortDescription>CC CANDLE JUNIPER & GINGER XMAS 3</ShortDescription>
<Quantity>1</Quantity>
<UnitOfMeasure>EACH</UnitOfMeasure>
<UnitPrice>45.95</UnitPrice>
<TotalAmount>45.95</TotalAmount>
<LineTax>0.00</LineTax>
<LineDiscount>0.00</LineDiscount>
<LineCharge>15.95</LineCharge>
<ExtendedAmount>45.95</ExtendedAmount>
<OriginalQty>0</OriginalQty>
<ChangedQty>0</ChangedQty>
<Messages>
<Message>
<MessageType/>
<MessageText/>
</Message>
</Messages>
<Status/>
</OrderLine>
</OrderLines>
</Delivery>
</Deliveries>
</data>
</content>
</test>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tanuja,
Please provide exact input xml payload during runtime.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.