I am getting error for below statement.

string xmloutput = '<?xml version="1.0" encoding="UTF-8"?><ns2:gaTransactionType xmlns:ns2="http://abc.com">gaPaymentTransaction.xsd "> 
    <merchantName>Test Merchant</merchantName> 
    <summaryDescription>This is a test.</summaryDescription>     
            <gaoDescription>BORDER FD</gaoDescription> 
  • Please clarify more. When are getting the above mentioned error? What are you trying to achieve?
    – sfdcFanBoy
    Commented Nov 6, 2017 at 8:34
  • getting error after single quote ( '< here). I have written a webservice class and getting on error on this line on saving
    – devsfdc
    Commented Nov 6, 2017 at 8:39

2 Answers 2


You are facing this issue because you are trying to add multi line statement. You can't directly add this. You have two options here.

  • Convert this into single line and then add

    <?xml version="1.0" encoding="UTF-8"?><ns2:gaTransactionType xmlns:ns2="http://abc.com">gaPaymentTransaction.xsd "><merchantName>Test Merchant</merchantName><merchantNumber>SNA_TEST</merchantNumber><service>SNA_TEST_DONATION</service><orderNumber>1001</orderNumber><gaBatchAgency>SNA</gaoBatchAgency><gaDocNoAgency>SNA</gaoDocNoAgency><totalAmount>5000</totalAmount><summaryDescription>This is a test.</summaryDescription><test>test</test><lineItemList><lineItem><gaoProductCode>SN000001</gaoProductCode><gaoAgency>SNA</gaoAgency><function>19000</function><revenueSource>4612</revenueSource><departmentRevenueSource></departmentRevenueSource><accountingTemplate></accountingTemplate><gaoDescription>BORDER FD</gaoDescription><amount>5000</amount><quantity>1</quantity></lineItem></lineItemList></ns2:gaTransactionType>

  • Second option to you need to do something like. Add them together and then use.

     string xmloutput = 'gaPaymentTransaction.xsd ">'+ 
        'Test Merchant '+
                // complete code
    '</ ns2:gaTransactionType>';

I found a better solution for this issue, you should create a custom laber for your kml script, and inside the apex code you can assign the custom label value to your variable.

  • 3
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 27, 2021 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .