2

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> 
    <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>';
  • Please clarify more. When are getting the above mentioned error? What are you trying to achieve? – sfdcFanBoy Nov 6 '17 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 Nov 6 '17 at 8:39
3

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 '+
        'SNA_TEST'+ 
        'SNA_TEST_DONATION'+
    
    
                // complete code
        '</lineItem>'+ 
    '</lineItemList>'+ 
    
    '</ ns2:gaTransactionType>';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.