Req :-  Custom Settings :-  Vacancy Media
                Fields:-   Name
        Map -- mapvacancymedia1

i have created a map mapvacanymedia1 in which i am fetching the values from the above custom setting and i need to create an XML file for the same.

But i am geeting error as : SObject row does not allow errors

Please help me to generate the XML for the same.

Code as below.

                        for(integer i=0;i<=vacancyMediaMapping.size();i++){
                            xmlW.writeCharacters(vacancyMediaMapping.get('Client Logo').Type__c);
                            xmlW.writeCharacters(vacancyMediaMapping.get('Job Video').Area__c);
                            xmlW.writeCharacters(vacancyMediaMapping.get('Client Video').Path__c);
                            System.debug('Debug at 743');
  • Please use relevant tags. This question is not related to salesforce1-app or continuous-integration.
    – David Reed
    Commented Jan 17, 2019 at 14:27

1 Answer 1


When using a generator, you need to make sure you close all the elements you open (each "writeStartElement" must be paired with a "writeEndElement"). Because this can get complicated, I generally recommend using Dom.Document directly instead of using a generator. There are simply too many things that can go wrong. I don't want to take any presumptions about your data, but if you insist on using the generator, you need to remember to close each element you open.


Dom.Document doc = new Dom.Document();
Dom.XmlNode root = doc.createRootElement('demo',null,null);


Dom.XmlNode vacancyMediaNode = root.addChildElement('VacancyMedia',null,null);
Dom.XmlNode typeNode = vacancyMediaNode.addChileElement('Type',null,null);
typeNode.addTextNode(vacancyMediaMapping.get('Client Logo').Type__c);
Dom.XmlNode areaNode = vacancyMediaNode.addChildElement('Area',null,null);
areaNode.addTextNode(vacancyMediaMapping.get('Job Video').Area__c);
Dom.XmlNode pathNode = vacancyMediaNode.addChildElement('Path',null,null);
pathNode.addTextNode(vacancyMediaMapping.get('Client Video').Path__c);


String xmlString = doc.toXmlString();
  • Thanks !!! can you give me the any example how to use the Dom.Document?? Commented Jan 17, 2019 at 14:01
  • @AbhijeetKumar you can find example here: Reading and Writing XML Using the DOM Commented Jan 17, 2019 at 14:05
  • @AbhijeetKumar I added an example that shows how the parts might work. You'll need to do additional work as necessary.
    – sfdcfox
    Commented Jan 17, 2019 at 14:15
  • Hi Currently i am not allowed to use the Dom.document ....as per project requirement , and after closing all the tab still i am getting the error "SObject row does not allow errors". Please help me out for this one. Commented Jan 20, 2019 at 2:23
  • @AbhijeetKumar That error is not at all related to this code. Consider asking a new question so it can get appropriate attention.
    – sfdcfox
    Commented Jan 20, 2019 at 4:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .