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
Brad007Brad007 

Can a List<Object> be converted to a XML string?

Hi,

 

Can the  List<AP_Application__c> APImagefiles  object be converted to a XML string to pass it to a .Net webservice.

I am trying to use the XmlStreamWriter class to build the Xml can anyone please suggest how to build the Xml with the list object. And also for each record in the List i would want to add the string value p for each record.

 

Thanks in Adavnce..

 

public class APImageUpdates {
  
  string Test;
  public void APImagesMissing()
  {
    string Photo1 = 'P1';
    string Photo2 = 'P2';
    string Photo3 = 'P3';
    string Photo4 = 'P4';
    List<Contact> APContacts = new List<Contact>();
    List<AP_Application__c> APImagefiles = new List<AP_Application__c>();    
    

    //Loop through Contacts for Available AuPairs 
    for(Contact contact: APContacts) 
    {
      system.debug('Entered the List');      
      if(contact.AP_Status__c =='Available' && contact.RecordTypeId =='012300000000AHhAAM')
      {              
        for(AP_Application__c APAppObj: [Select Id,Au_Pair__c,AP_Folder_Name__c From AP_Application__c where Au_Pair__c =: contact.Id])
        {
          if(APAppObj.IsExist_Photo1__c == false || APAppObj.IsExist_Photo2__c == false || APAppObj.IsExist_Photo3__c == false || APAppObj.IsExist_Photo4__c == false)
          {          
              APImagefiles.add(APAppObj);                          
          }
          update APImagefiles;
        }
      }
    }
  }
    
    public String getXml()
   {
       Xmlstreamwriter w = new Xmlstreamwriter();
       w.writeStartDocument(null, '1.0');
       w.writeProcessingInstruction('target', 'data');
      return 'Test';
    
   }   
    
     //Create the Stub
     AJAXOrg.AjaxSoap service = new AJAXOrg.AjaxSoap();       
     // Make the Web service call      
       String output = service.GAPNetworkImages(Test);