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
carlocarlo 

Dom.XMLNode hitting Unknown Limit

Hello

 

I am exporting data from SF to a third party system using XML.  I have setup a VF Page with a Controller to collect the data required and format this into XML using the Dom Document and XMLNode objects. This was working fine until I started getting the occasional Time Limit Exceeded on the VF Page. I presume I am hitting some kind of limit as the volume of data required in this export has increased as we have been using SF and adding more data.

 

I have identified that the problem is the Dom.XMLNode object because I created a copy of my controller without it and instead built the XML as a string.  This works fine.

 

The VF page just contains one line which outputs the string to the screen.

 

My Dom.XMLNode Controller gets data from a Master Object and 3 Children.  It uses a List for the Master Object and then 3 Maps for the Children.  I am confident this is not causing me any problems because this is replicated in my String based controller which works fine.

 

Once I have the data loaded I then set up my Dom.Document and XMLNode root element.

 

I then enter a Loop through my Master Object List:

 

Dom.XMLNode Master = root.addChildElement('Master', null, null);

Master.addChildElement('MasterDataField1', null, null).addTextNode('DataValue1');
  Master.addChildElement('MasterDataField2', null, null).addTextNode('DataValue2');
  Master.addChildElement('MasterDataField3', null, null).addTextNode('DataValue3');

 

I then have a Loop to go through Child1 Map for this Master record

 

Dom.XMLNode Child1 = Master.addChildElement('Child1', null, null);

Child1.addChildElement('Child1DataField1', null, null).addTextNode('Child1Value1');
  Child1.addChildElement('Child1DataField2', null, null).addTextNode('Child1Value2');
  Child1.addChildElement('Child1DataField3', null, null).addTextNode('Child1Value3');

 

I then have another Loop to go through Child2 Map for this Master record

 

Dom.XMLNode Child2 = Master.addChildElement('Child2', null, null);

  Child1.addChildElement('Child2DataField1', null, null).addTextNode('Child2Value1');
   Child1.addChildElement('Child2DataField2', null, null).addTextNode('Child2Value2');
   Child1.addChildElement('Child2DataField3', null, null).addTextNode('Child2Value3');

 

  I then have another Loop to go through Child3 Map for this Master record

 

  Dom.XMLNode Child2 = Master.addChildElement('Child2', null, null);

Child3.addChildElement('Child3DataField1', null, null).addTextNode('Child3Value1');
Child3.addChildElement('Child3DataField2', null, null).addTextNode('Child3Value2');
    Child3.addChildElement('Child3DataField3', null, null).addTextNode('Child3Value3');

 

I then return master.toXMLString() 

 

So does anyone see any problems with my code or where it might be inefficient?

 

Thanks

 

Carlo