How to remove & (ampersand) sign from XML posting

Giganews Newsgroups
Subject: How to remove & (ampersand) sign from XML posting
Posted by:  Thien Tang (t…@tctdigital.com)
Date: Thu, 17 May 2007

Hi
When I submitted an XML section (below) the server at the vendor site saw
the & in place of the carriage return/line feed characters and returned an
'Cannot parse XML' error.

This is the content
------------------

<?xml version="1.0" encoding="UTF-8"?>
<Order>
<StoreID>xxxxx</StoreID>
<Passphrase>xxx</Passphrase>
<Subtotal>10.00</Subtotal>
<PaymentType>CC</PaymentType>
<CardAction>0</CardAction>
<CardNumber>4111111111111111</CardNumber>
<CardExpMonth>02</CardExpMonth>
<CardExpYear>08</CardExpYear>
<CardIDNumber>3422</CardIDNumber>
</Order>

This is the procedure that sent it:
--------------------------------
procedure TmainForm.Button1Click(Sender: TObject);
>    var
>        XML: TStringList;
>        Response: String;
>    begin
>        XML := TStringList.Create;
>        try
>            XML.LoadFromFile('test2.xml');
>            IdHTTP1.Request.ContentType :=
> 'application/x-www-form-urlencoded';
>            Response :=
> IdHTTP1.Post('https://somewebsitesome:7777/Messenger/XMLMessenger',
> XML);
>        finally
>            XML.Free;
>        end;
>    end;

This is what the vendor received (with 'Cannot parse XML' error)
------------------------------------------------------------

<?xml version="1.0"%20encoding="UTF-8"?%3E&<Order>&  <StoreID>xxxxx
</StoreID>&  <Passphrase>xxx</Passphrase>&  <Subtotal>10.00</Subtota
l>&        <PaymentType>CC</PaymentType>&      <CardAction>0</CardAction>&
<CardNumber>4111111111111111</CardNumber>&
<CardExpMonth>02</CardExpMonth>&
        <CardExpYear>08</CardExpYear>&<CardIDNumber>3422</CardIDNumber>&</Order>

Any help would be greatly appreciated.

Tim

Replies