• rajashekar reddy 18
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
@RestResource(urlMapping='/property/*')
global with sharing class PropertyApi {
   
    @RestResource(urlMapping='/property/property')
    @HttpGet
    
    global static List<CustomListing> getProperties() {
       
        List<pba__Listing__c> properties=[SELECT Id,Name,ListingId__c,pba__Property__c,Common_Charges__c,pba__Address_pb__c,pba__City_pb__c,
                                          pba__State_pb__c,pba__PostalCode_pb__c,pba__Country_pb__c,Street_Intersection__c,Display_Address__c,
                                          pba__Status__c,Listing_Status__c,pba__ListingType__c,pba__ListingPrice_pb__c,pba__Listing_Website__c,
                                          Listed_Date__c,Listing_Email__c,Move_in_Date__c,HasGarden__c,HasBalcony__c,HasTerrace__c,
                                          HasPrivateRoofDeck__c,HasPrivateCourtyard__c,HasRoofGarden__c,Building_Type__c,Block__c,                                                                  
                                          Fee_Type__c,pba__Description_pb__c,pba__Bedrooms_pb__c,pba__FullBathrooms_pb__c,Rooms__c,pba__LotSize_pb__c,    
                                          pba__PropertyType__c,Building_Description__c,Condition__c,                                                                                                               
                                          pba__Listing_Agent_Firstname__c,pba__Listing_Agent_Lastname__c,pba__Listing_Agent_Email__c,                                              
                                          pba__Listing_Agent_Photo__c,pba__Listing_Agent_Mobil_Phone__c,pba__Listing_Agent_Phone__c,Listing_Agent_Brokerage_Name__c,                                              
                                          pba__Listing_Agent_Street__c,pba__Listing_Agent_City__c,pba__Listing_Agent_Zip__c,Neighborhood__c,Neighborhood_Description__c,
                                          Appliances__c,Cooling_Systems__c,Exterior_Types__c,of_Floors__c,NewConstruction__c,Listing_Secondary_Agent_Firstname__c,                                          
                                          Listing_Secondary_Agent_Lastname__c,Listing_Secondary_Agent_Email__c,Listing_Secondary_Agent_Photo__c,                                          
                                          Listing_Secondary_Agent_Mobil_Phone__c,Listing_Secondary_Agent_Phone__c,Listing_Secondary_Agent_Brokerage_Name__c,
                                          Listing_Secondary_Agent_Street__c,Listing_Secondary_Agent_City__c,Listing_Secondary_Agent_Zip__c,                                          
                                          Floorplan_URL__c,pba__Listing_Agent_Website__c,Sale_Price__c,Sale_Date__c from pba__Listing__c ];
       
        List<CustomListing> objlistCustomListing=new List<CustomListing>();
      
        for(pba__Listing__c Listing:properties){            
        	//CustomListing objCustomListing=new CustomListing();
       		
        List<pba__PropertyMedia__c> objPropertyMedia=new List<pba__PropertyMedia__c>();
         objPropertyMedia=[select Id,pba__Property__c,pba__URL__c from pba__PropertyMedia__c where pba__Property__c=:Listing.pba__Property__c];
        objlistCustomListing.add(new CustomListing(Listing,objPropertyMedia));
            //objCustomListing.objPropertyMedia=objPropertyMedia;
        //objlistCustomListing.add(objCustomListing);
        }       
        return objlistCustomListing;
}

global class CustomListing  
	{
    	pba__Listing__c objListing{get;set;}
    	List<pba__PropertyMedia__c> objPropertyMedia{get;set;}
        CustomListing(pba__Listing__c listing,List<pba__PropertyMedia__c> media){
            objListing = listing;
            objPropertyMedia = media;
        }
	}
}

 
here i am generating xml file.proviously it was working fine now i am getting error too many soql queries.
here i am generating XML file.it was working fine till now. but now iam facing this exception.
my code is

public class OutBoundListingData {
    
    public static string genratedXML{get;set;}
    
    public OutBoundListingData()
    {
        GenerateListingXML();
    }
    
    public static List<pba__Listing__c> getListingRecords()
    {
        List<pba__Listing__c> objListListing=[select Id,ListingId__c,pba__Property__c,Common_Charges__c,pba__Address_pb__c,
                                              of_Units__c,pba__City_pb__c,pba__State_pb__c,pba__PostalCode_pb__c,
                                              pba__Latitude_pb__c,pba__Longitude_pb__c,pba__Country_pb__c
                                              ,Street_Intersection__c,Display_Address__c,pba__Status__c,
                                              Listing_Status__c,pba__ListingType__c,pba__ListingPrice_pb__c,
                                              pba__Listing_Website__c,Listed_Date__c,Listing_Email__c,Move_in_Date__c,
                                              HasGarden__c,HasBackyard__c,HasBalcony__c,HasTerrace__c,HasPrivateRoofDeck__c,
                                              HasPrivateCourtyard__c,HasStorageSpace__c,HasGarage__c,HasRoofGarden__c,
                                              HasHealthClub__c,HasCourtyard__c,UtilitiesIncluded__c,HasWasherDryer__c,
                                              Pets_Allowed__c,Commission__c,OPPaidToCobroker__c,Lease_Term_Type__c,
                                              Lease_Type__c,Move_In_Fee__c,Move_Out_Fee__c,Pet_Security_Amount__c,
                                              Security_Deposit__c,Fee_Type__c,Name,pba__Description_pb__c,pba__Bedrooms_pb__c,
                                              pba__FullBathrooms_pb__c,Rooms__c,pba__LotSize_pb__c,pba__YearBuilt_pb__c,
                                              Prepost__c,pba__PropertyType__c,Building_Description__c,Condition__c,
                                              Exposures__c,Showing_Instructions__c,View__c,NewDevelopment__c,
                                              Construction_Era__c,Building_Type__c,Lobby_Attendance__c,Block__c,
                                              Management_Company__c,pba__Listing_Agent_Firstname__c,
                                              pba__Listing_Agent_Lastname__c,pba__Listing_Agent_Email__c,
                                              pba__Listing_Agent_Photo__c,pba__Listing_Agent_Mobil_Phone__c,
                                              pba__Listing_Agent_Phone__c,Listing_Agent_Brokerage_Name__c,
                                              pba__Listing_Agent_Street__c,pba__Listing_Agent_City__c,pba__Listing_Agent_Zip__c,
                                              Neighborhood__c,Neighborhood_Description__c,Appliances__c,Cooling_Systems__c,
                                              Elevator__c,Exterior_Types__c,Floor_Coverings__c,of_Floors__c,NewConstruction__c ,
                                              Listing_Secondary_Agent_Firstname__c,Listing_Secondary_Agent_Lastname__c,
                                              Listing_Secondary_Agent_Email__c,Listing_Secondary_Agent_Photo__c,
                                              Listing_Secondary_Agent_Mobil_Phone__c,Listing_Secondary_Agent_Phone__c,
                                              Listing_Secondary_Agent_Brokerage_Name__c,Listing_Secondary_Agent_Street__c,
                                              Listing_Secondary_Agent_City__c,Listing_Secondary_Agent_Zip__c ,
                                              Floorplan_URL__c,Listing_URL__c from pba__Listing__c where RLSListingKey__c=null];
        return objListListing;
    }
    public static void GenerateListingXML()
    {
        XmlStreamWriter w =new XmlStreamWriter();  
        w.writeStartElement(null,'Listings',null);            
            for(pba__Listing__c Item : getListingRecords()){               
                w.writeStartElement(null,'Listing',null);               
                w.writeStartElement(null, 'Type', null);
                w.writeCharacters(Item.pba__ListingType__c);  
                w.writeEndElement();
                w.writeStartElement(null, 'WebID', null);
                w.writeCharacters(Item.Id);
                w.writeEndElement();
                w.writeStartElement(null,'ListingId', null);
                w.writeCharacters(Item.ListingId__c);
                w.writeEndElement();
                w.writeStartElement(null, 'CommonCharges', null);
                if(Item.Common_Charges__c!=null)
                    w.writeCharacters(String.valueOf(Item.Common_Charges__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'Floorplans', null);               
                w.writeStartElement(null, 'Floorplan', null);
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Floorplan_URL__c!=null)
                    w.writeCharacters(String.valueOf(Item.Floorplan_URL__c));  
                w.writeEndElement();   
                w.writeEndElement();                 
                w.writeEndElement();                 
                w.writeStartElement(null, 'Commission', null);
                if(Item.Commission__c!=null)
                    w.writeCharacters(String.valueOf(Item.Commission__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'UnitNumber', null);
                if(Item.of_Units__c!=null)
                    w.writeCharacters(String.valueOf(Item.of_Units__c));  
                w.writeEndElement();    
                w.writeStartElement(null, 'City', null);
                if(Item.pba__City_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__City_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'State', null);
                if(Item.pba__State_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__State_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Zip', null);
                if(Item.pba__PostalCode_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PostalCode_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lat', null);
                if(Item.pba__Latitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Latitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Long', null);
                if(Item.pba__Longitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Longitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'County', null);
                if(Item.pba__Country_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Country_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'StreetIntersection', null);
                if(Item.Street_Intersection__c!=null)
                    w.writeCharacters(String.valueOf(Item.Street_Intersection__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DisplayAddress', null);
                if(Item.Display_Address__c!=null)
                    w.writeCharacters(String.valueOf(Item.Display_Address__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Neighborhood', null);
                if(Item.Neighborhood__c!=null)
                    w.writeCharacters(String.valueOf(Item.Neighborhood__c));  
                w.writeEndElement();               
                w.writeEndElement();
                w.writeStartElement(null, 'ListingDetails', null);               
                w.writeStartElement(null, 'Status', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingStatus', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingType', null);
                if(Item.pba__ListingType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Price', null);
                if(Item.pba__ListingPrice_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingPrice_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingUrl', null);
                if(Item.pba__Listing_Website__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Listing_Website__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateListed', null);
                if(Item.Listed_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listed_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingEmail', null);
                if(Item.Listing_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateAvailable', null);
                if(Item.Move_in_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Move_in_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarden', null);
                if(Item.HasGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBackyard', null);
                if(Item.HasBackyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBackyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBalcony', null);
                if(Item.HasBalcony__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBalcony__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasTerrace', null);
                if(Item.HasTerrace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasTerrace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateRoofDeck', null);
                if(Item.HasPrivateRoofDeck__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateRoofDeck__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateCourtyard', null);
                if(Item.HasPrivateCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasStorageSpace', null);
                if(Item.HasStorageSpace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasStorageSpace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarage', null);
                if(Item.HasGarage__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarage__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasRoofGarden', null);
                if(Item.HasRoofGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasRoofGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasHealthClub', null);
                if(Item.HasHealthClub__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasHealthClub__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasCourtyard', null);
                if(Item.HasCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'UtilitiesIncluded', null);
                if(Item.UtilitiesIncluded__c!=null)
                    w.writeCharacters(String.valueOf(Item.UtilitiesIncluded__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasWasherDryer', null);
                if(Item.HasWasherDryer__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasWasherDryer__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'AllowsPets', null);
                if(Item.Pets_Allowed__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pets_Allowed__c));  
                w.writeEndElement();                                 
                w.writeStartElement(null, 'PetSecurityAmount', null);
                if(Item.Pet_Security_Amount__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pet_Security_Amount__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'SecurityDeposit', null);
                if(Item.Security_Deposit__c!=null)
                    w.writeCharacters(String.valueOf(Item.Security_Deposit__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'FeeType', null);
                if(Item.Fee_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Fee_Type__c));  
                w.writeEndElement();                
                w.writeEndElement();
                w.writeStartElement(null, 'BasicDetails', null);                
                w.writeStartElement(null, 'Title', null);
                if(Item.Name!=null)
                    w.writeCharacters(String.valueOf(Item.Name));  
                w.writeEndElement();
                w.writeStartElement(null, 'Description', null);
                if(Item.pba__Description_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Description_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Bedrooms', null);
                if(Item.pba__Bedrooms_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Bedrooms_pb__c));  
                w.writeEndElement();                  
                w.writeStartElement(null, 'Prepost', null);
                if(Item.Prepost__c!=null)
                    w.writeCharacters(String.valueOf(Item.Prepost__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PropertyType', null);
                if(Item.pba__PropertyType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PropertyType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingDescription', null);
                if(Item.Building_Description__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Description__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Condition', null);
                if(Item.Condition__c!=null)
                    w.writeCharacters(String.valueOf(Item.Condition__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Exposures', null);
                if(Item.Exposures__c!=null)
                    w.writeCharacters(String.valueOf(Item.Exposures__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ShowingInstructions', null);
                if(Item.Showing_Instructions__c!=null)
                    w.writeCharacters(String.valueOf(Item.Showing_Instructions__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Views', null);
                if(Item.View__c!=null)
                    w.writeCharacters(String.valueOf(Item.View__c));  
                w.writeEndElement();                          
                w.writeEndElement();            
                w.writeStartElement(null, 'Building', null);               
                w.writeStartElement(null, 'NewDevelopment', null);
                if(Item.NewDevelopment__c!=null)
                    w.writeCharacters(String.valueOf(Item.NewDevelopment__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ConstructionEra', null);
                if(Item.Construction_Era__c!=null)
                    w.writeCharacters(String.valueOf(Item.Construction_Era__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LobbyAttendance', null);
                if(Item.Lobby_Attendance__c!=null)
                    w.writeCharacters(String.valueOf(Item.Lobby_Attendance__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Block', null);
                if(Item.Block__c!=null)
                    w.writeCharacters(String.valueOf(Item.Block__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lot', null);
                if(Item.pba__LotSize_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__LotSize_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ManagementCompany', null);
                if(Item.Management_Company__c!=null)
                    w.writeCharacters(String.valueOf(Item.Management_Company__c));  
                w.writeEndElement();               
                w.writeEndElement();             
                w.writeStartElement(null, 'Pictures', null);
                List<pba__PropertyMedia__c> ListImages= [select id,pba__URL__c from pba__PropertyMedia__c where pba__Property__c=:Item.pba__Property__c ];               
                for(pba__PropertyMedia__c objImages: ListImages)
                {
                    w.writeStartElement(null, 'Picture', null);                   
                    w.writeStartElement(null, 'PictureUrl', null);  
                    if(objImages.pba__URL__c != null)
                        w.writeCharacters(String.valueOf(objImages.pba__URL__c));  
                    w.writeEndElement();                    
                    w.writeEndElement();
                }
                w.writeEndElement();            
                w.writeStartElement(null, 'Videos', null);
                w.writeEndElement();
                w.writeStartElement(null, 'SecondaryAgent', null);               
                w.writeStartElement(null, 'FirstName', null);
                if(Item.Listing_Secondary_Agent_Firstname__c !=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Firstname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LastName', null);
                if(Item.Listing_Secondary_Agent_Lastname__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Lastname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'EmailAddress', null);
                if(Item.Listing_Secondary_Agent_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Listing_Secondary_Agent_Photo__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Photo__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'MobilePhoneLineNumber', null);
                if(Item.Listing_Secondary_Agent_Mobil_Phone__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Mobil_Phone__c));  
                w.writeEndElement();
               
              
               
          w.writeEndElement();
        string xml = w.getXmlString();
        w.close();
        genratedXML='<?xml version="1.0"?>'+xml;
    }
}

 
here i am generating xml file.proviously it was working fine now i am getting error too many soql queries.
here i am generating XML file.it was working fine till now. but now iam facing this exception.
my code is

public class OutBoundListingData {
    
    public static string genratedXML{get;set;}
    
    public OutBoundListingData()
    {
        GenerateListingXML();
    }
    
    public static List<pba__Listing__c> getListingRecords()
    {
        List<pba__Listing__c> objListListing=[select Id,ListingId__c,pba__Property__c,Common_Charges__c,pba__Address_pb__c,
                                              of_Units__c,pba__City_pb__c,pba__State_pb__c,pba__PostalCode_pb__c,
                                              pba__Latitude_pb__c,pba__Longitude_pb__c,pba__Country_pb__c
                                              ,Street_Intersection__c,Display_Address__c,pba__Status__c,
                                              Listing_Status__c,pba__ListingType__c,pba__ListingPrice_pb__c,
                                              pba__Listing_Website__c,Listed_Date__c,Listing_Email__c,Move_in_Date__c,
                                              HasGarden__c,HasBackyard__c,HasBalcony__c,HasTerrace__c,HasPrivateRoofDeck__c,
                                              HasPrivateCourtyard__c,HasStorageSpace__c,HasGarage__c,HasRoofGarden__c,
                                              HasHealthClub__c,HasCourtyard__c,UtilitiesIncluded__c,HasWasherDryer__c,
                                              Pets_Allowed__c,Commission__c,OPPaidToCobroker__c,Lease_Term_Type__c,
                                              Lease_Type__c,Move_In_Fee__c,Move_Out_Fee__c,Pet_Security_Amount__c,
                                              Security_Deposit__c,Fee_Type__c,Name,pba__Description_pb__c,pba__Bedrooms_pb__c,
                                              pba__FullBathrooms_pb__c,Rooms__c,pba__LotSize_pb__c,pba__YearBuilt_pb__c,
                                              Prepost__c,pba__PropertyType__c,Building_Description__c,Condition__c,
                                              Exposures__c,Showing_Instructions__c,View__c,NewDevelopment__c,
                                              Construction_Era__c,Building_Type__c,Lobby_Attendance__c,Block__c,
                                              Management_Company__c,pba__Listing_Agent_Firstname__c,
                                              pba__Listing_Agent_Lastname__c,pba__Listing_Agent_Email__c,
                                              pba__Listing_Agent_Photo__c,pba__Listing_Agent_Mobil_Phone__c,
                                              pba__Listing_Agent_Phone__c,Listing_Agent_Brokerage_Name__c,
                                              pba__Listing_Agent_Street__c,pba__Listing_Agent_City__c,pba__Listing_Agent_Zip__c,
                                              Neighborhood__c,Neighborhood_Description__c,Appliances__c,Cooling_Systems__c,
                                              Elevator__c,Exterior_Types__c,Floor_Coverings__c,of_Floors__c,NewConstruction__c ,
                                              Listing_Secondary_Agent_Firstname__c,Listing_Secondary_Agent_Lastname__c,
                                              Listing_Secondary_Agent_Email__c,Listing_Secondary_Agent_Photo__c,
                                              Listing_Secondary_Agent_Mobil_Phone__c,Listing_Secondary_Agent_Phone__c,
                                              Listing_Secondary_Agent_Brokerage_Name__c,Listing_Secondary_Agent_Street__c,
                                              Listing_Secondary_Agent_City__c,Listing_Secondary_Agent_Zip__c ,
                                              Floorplan_URL__c,Listing_URL__c from pba__Listing__c where RLSListingKey__c=null];
        return objListListing;
    }
    public static void GenerateListingXML()
    {
        XmlStreamWriter w =new XmlStreamWriter();  
        w.writeStartElement(null,'Listings',null);            
            for(pba__Listing__c Item : getListingRecords()){               
                w.writeStartElement(null,'Listing',null);               
                w.writeStartElement(null, 'Type', null);
                w.writeCharacters(Item.pba__ListingType__c);  
                w.writeEndElement();
                w.writeStartElement(null, 'WebID', null);
                w.writeCharacters(Item.Id);
                w.writeEndElement();
                w.writeStartElement(null,'ListingId', null);
                w.writeCharacters(Item.ListingId__c);
                w.writeEndElement();
                w.writeStartElement(null, 'CommonCharges', null);
                if(Item.Common_Charges__c!=null)
                    w.writeCharacters(String.valueOf(Item.Common_Charges__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'Floorplans', null);               
                w.writeStartElement(null, 'Floorplan', null);
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Floorplan_URL__c!=null)
                    w.writeCharacters(String.valueOf(Item.Floorplan_URL__c));  
                w.writeEndElement();   
                w.writeEndElement();                 
                w.writeEndElement();                 
                w.writeStartElement(null, 'Commission', null);
                if(Item.Commission__c!=null)
                    w.writeCharacters(String.valueOf(Item.Commission__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'UnitNumber', null);
                if(Item.of_Units__c!=null)
                    w.writeCharacters(String.valueOf(Item.of_Units__c));  
                w.writeEndElement();    
                w.writeStartElement(null, 'City', null);
                if(Item.pba__City_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__City_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'State', null);
                if(Item.pba__State_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__State_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Zip', null);
                if(Item.pba__PostalCode_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PostalCode_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lat', null);
                if(Item.pba__Latitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Latitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Long', null);
                if(Item.pba__Longitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Longitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'County', null);
                if(Item.pba__Country_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Country_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'StreetIntersection', null);
                if(Item.Street_Intersection__c!=null)
                    w.writeCharacters(String.valueOf(Item.Street_Intersection__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DisplayAddress', null);
                if(Item.Display_Address__c!=null)
                    w.writeCharacters(String.valueOf(Item.Display_Address__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Neighborhood', null);
                if(Item.Neighborhood__c!=null)
                    w.writeCharacters(String.valueOf(Item.Neighborhood__c));  
                w.writeEndElement();               
                w.writeEndElement();
                w.writeStartElement(null, 'ListingDetails', null);               
                w.writeStartElement(null, 'Status', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingStatus', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingType', null);
                if(Item.pba__ListingType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Price', null);
                if(Item.pba__ListingPrice_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingPrice_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingUrl', null);
                if(Item.pba__Listing_Website__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Listing_Website__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateListed', null);
                if(Item.Listed_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listed_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingEmail', null);
                if(Item.Listing_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateAvailable', null);
                if(Item.Move_in_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Move_in_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarden', null);
                if(Item.HasGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBackyard', null);
                if(Item.HasBackyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBackyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBalcony', null);
                if(Item.HasBalcony__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBalcony__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasTerrace', null);
                if(Item.HasTerrace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasTerrace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateRoofDeck', null);
                if(Item.HasPrivateRoofDeck__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateRoofDeck__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateCourtyard', null);
                if(Item.HasPrivateCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasStorageSpace', null);
                if(Item.HasStorageSpace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasStorageSpace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarage', null);
                if(Item.HasGarage__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarage__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasRoofGarden', null);
                if(Item.HasRoofGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasRoofGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasHealthClub', null);
                if(Item.HasHealthClub__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasHealthClub__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasCourtyard', null);
                if(Item.HasCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'UtilitiesIncluded', null);
                if(Item.UtilitiesIncluded__c!=null)
                    w.writeCharacters(String.valueOf(Item.UtilitiesIncluded__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasWasherDryer', null);
                if(Item.HasWasherDryer__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasWasherDryer__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'AllowsPets', null);
                if(Item.Pets_Allowed__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pets_Allowed__c));  
                w.writeEndElement();                                 
                w.writeStartElement(null, 'PetSecurityAmount', null);
                if(Item.Pet_Security_Amount__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pet_Security_Amount__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'SecurityDeposit', null);
                if(Item.Security_Deposit__c!=null)
                    w.writeCharacters(String.valueOf(Item.Security_Deposit__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'FeeType', null);
                if(Item.Fee_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Fee_Type__c));  
                w.writeEndElement();                
                w.writeEndElement();
                w.writeStartElement(null, 'BasicDetails', null);                
                w.writeStartElement(null, 'Title', null);
                if(Item.Name!=null)
                    w.writeCharacters(String.valueOf(Item.Name));  
                w.writeEndElement();
                w.writeStartElement(null, 'Description', null);
                if(Item.pba__Description_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Description_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Bedrooms', null);
                if(Item.pba__Bedrooms_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Bedrooms_pb__c));  
                w.writeEndElement();                  
                w.writeStartElement(null, 'Prepost', null);
                if(Item.Prepost__c!=null)
                    w.writeCharacters(String.valueOf(Item.Prepost__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PropertyType', null);
                if(Item.pba__PropertyType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PropertyType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingDescription', null);
                if(Item.Building_Description__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Description__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Condition', null);
                if(Item.Condition__c!=null)
                    w.writeCharacters(String.valueOf(Item.Condition__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Exposures', null);
                if(Item.Exposures__c!=null)
                    w.writeCharacters(String.valueOf(Item.Exposures__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ShowingInstructions', null);
                if(Item.Showing_Instructions__c!=null)
                    w.writeCharacters(String.valueOf(Item.Showing_Instructions__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Views', null);
                if(Item.View__c!=null)
                    w.writeCharacters(String.valueOf(Item.View__c));  
                w.writeEndElement();                          
                w.writeEndElement();            
                w.writeStartElement(null, 'Building', null);               
                w.writeStartElement(null, 'NewDevelopment', null);
                if(Item.NewDevelopment__c!=null)
                    w.writeCharacters(String.valueOf(Item.NewDevelopment__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ConstructionEra', null);
                if(Item.Construction_Era__c!=null)
                    w.writeCharacters(String.valueOf(Item.Construction_Era__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LobbyAttendance', null);
                if(Item.Lobby_Attendance__c!=null)
                    w.writeCharacters(String.valueOf(Item.Lobby_Attendance__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Block', null);
                if(Item.Block__c!=null)
                    w.writeCharacters(String.valueOf(Item.Block__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lot', null);
                if(Item.pba__LotSize_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__LotSize_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ManagementCompany', null);
                if(Item.Management_Company__c!=null)
                    w.writeCharacters(String.valueOf(Item.Management_Company__c));  
                w.writeEndElement();               
                w.writeEndElement();             
                w.writeStartElement(null, 'Pictures', null);
                List<pba__PropertyMedia__c> ListImages= [select id,pba__URL__c from pba__PropertyMedia__c where pba__Property__c=:Item.pba__Property__c ];               
                for(pba__PropertyMedia__c objImages: ListImages)
                {
                    w.writeStartElement(null, 'Picture', null);                   
                    w.writeStartElement(null, 'PictureUrl', null);  
                    if(objImages.pba__URL__c != null)
                        w.writeCharacters(String.valueOf(objImages.pba__URL__c));  
                    w.writeEndElement();                    
                    w.writeEndElement();
                }
                w.writeEndElement();            
                w.writeStartElement(null, 'Videos', null);
                w.writeEndElement();
                w.writeStartElement(null, 'SecondaryAgent', null);               
                w.writeStartElement(null, 'FirstName', null);
                if(Item.Listing_Secondary_Agent_Firstname__c !=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Firstname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LastName', null);
                if(Item.Listing_Secondary_Agent_Lastname__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Lastname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'EmailAddress', null);
                if(Item.Listing_Secondary_Agent_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Listing_Secondary_Agent_Photo__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Photo__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'MobilePhoneLineNumber', null);
                if(Item.Listing_Secondary_Agent_Mobil_Phone__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Mobil_Phone__c));  
                w.writeEndElement();
               
              
               
          w.writeEndElement();
        string xml = w.getXmlString();
        w.close();
        genratedXML='<?xml version="1.0"?>'+xml;
    }
}