function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sravana SudheerSravana Sudheer 

Unable to post Job to 3rd party service using REST Based Callout

Hi All,
Got an error saying that unable to Post the data to 3rd party service due to invalid XML in one of the Field which we are mapping from salesforce which is in HML format. Tried using CDATA tags, but seems out like it didn't resolve the issue. 
Error: <Message>XML INVALID, Your XML is not valid according to Export DTD. unknown-65b0270:0: validity error : Element JobDescription was declared #PCDATA but contains non text nodes unknown-65b0270:0: validity error : No declaration for element p unknown-65b0270:0: validity error : No declaration for attribute style of element p
Tried using the below code.
JobDescription= rev.Job_Description__c;    --> Job_Description__c contains html tags like <ul>, <p>,<span>  etc.
String[] JD = JobDescription.split('<br>');
        JobDescription='';
        string JobDescriptionP='';
        for(String s : JD){
        JobDescription = JobDescription+'<![CDATA[<br>]]>' +s+' ';
            string[] JDP=JobDescription.split('<p>');
            for(string p:JDP){
                JobDescriptionP = JobDescriptionP+'<![CDATA[<p>]]>'+p+' ';
                        system.debug('jdp-----'+JobDescriptionP);
            }
            JobDescription=JobDescriptionP;
        system.debug('jd++++'+JobDescription);
        }