process the modified xml and put write to file
19906
function processResult(context, lang, langJson, stringXmlJson) {
    var path = require('path');
    var q = require('q');
    var deferred = q.defer();

    var mapObj = {};
    // create a map to the actual string
    _.forEach(stringXmlJson.resources.string, function (val) {
        if (_.has(val, "$") && _.has(val["$"], "name")) {
            mapObj[val["$"].name] = val;
        }
    });

    var langJsonToProcess = _.assignIn(langJson.config_android, langJson.app, langJson.app_android);

    //now iterate through langJsonToProcess
    _.forEach(langJsonToProcess, function (val, key) {
        // positional string format is in Mac OS X format.  change to android format
        val = val.replace(/\$@/gi, "$s");
        val = val.replace(/\'/gi, "\\'");

        if (_.has(mapObj, key)) {
            // mapObj contains key. replace key
            mapObj[key]["_"] = val;
        } else {
            // add by inserting
            stringXmlJson.resources.string.push({
                _: val,
                '$': {name: key}
            });
        }
    });

    //save to disk
    var langDir = getLocalizationDir(context, lang);
    var filePath = getLocalStringXmlPath(context, lang);

    fs.ensureDir(langDir, function (err) {
        if (err) {
            throw err;
        }

        fs.writeFile(filePath, buildXML(stringXmlJson), {encoding: 'utf8'}, function (err) {
            if (err) throw err;
            console.log('Saved:' + filePath);
            return deferred.resolve();
        });
    });

    function buildXML(obj) {
        var builder = new xml2js.Builder();
        builder.options.renderOpts.indent = '\t';

        var x = builder.buildObject(obj);
        return x.toString();
    }

    return deferred.promise;
}
135395
def edit(request)
      render do |xml|
        xml.h2 "Update rack session"
        xml.p "Put marshalized and encoded with base64 ruby hash into the form"
        xml.form({
          :action  => action_path(:update),
          :method  => 'post',
          :enctype => 'application/x-www-form-urlencoded'
        }) do |form|
          form.input(:type => 'hidden', :name =>'_method', :value => 'put')
          form.textarea(:cols => 40, :rows => 10, :name => 'data') {}
          form.p do |p|
            p.input(:type => 'submit', :value => "Update")
          end
        end
      end
    end
1094844
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openCloseTag(
                ELEMENT_NAME,
                new XMLAttributeList().addAttribute("sequence", String.valueOf(sequence))
                .addAttribute("timestamp", String.valueOf(timestamp)).addAttribute("release", releaseName)
                .addAttribute("codeSize", String.valueOf(codeSize))
                .addAttribute("numClasses", String.valueOf(numClasses)));
    }
93250
def write(self):
        
        if not os.path.isdir(self._dirs['source_dir']):
            os.mkdir(self._dirs['source_dir'])

        fout = codecs.open(self._dirs['source_filename'], 'w', encoding="utf-8", errors="xmlcharrefreplace")
        fout.write(self._config_to_text())
        if self._content:
            fout.write('\n')
            fout.write(self._content)
            fout.write('\n')
        fout.close()
603157
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    super.xmlWriteOn(writer);
    
    writer.newLine();
    writer.taggedValue("subscriberID", _subState.getSubscriberID());

    writer.newLine();
    writer.startTag("topics");
    writer.indent();

    String[] topics = _subState.getTopics();

    if (topics != null)
    {
      for (int i = 0; i < topics.length; i++)
      {
        writer.newLine();
        writer.taggedValue("topic", topics[i]);
      }
    }

    writer.outdent();
    writer.newLine();
    writer.endTag("topics");
    writer.newLine();
    writer.taggedValue("toBeDeleted", toBeDeleted);
  }
549146
def write_xmlbif(self, filename):
        
        with open(filename, 'w') as fout:
            fout.write(self.__str__())
349325
public function flush(): void
    {
        if ($this->writeDocument === true) {
            $this->write($this->getXML());
        }

        parent::flush();
    }
1196705
def process_xml(self, xml):
        '''
        
        '''
        root = objectify.fromstring(xml)
        self.message_identifier = str(
            root.imsx_POXHeader.imsx_POXRequestHeaderInfo.
            imsx_messageIdentifier)
        try:
            result = root.imsx_POXBody.replaceResultRequest
            self.operation = REPLACE_REQUEST
            # Get result sourced id from resultRecord
            self.lis_result_sourcedid = result.resultRecord.\
                sourcedGUID.sourcedId
            self.score = str(result.resultRecord.result.
                             resultScore.textString)
        except:
            pass

        try:
            result = root.imsx_POXBody.deleteResultRequest
            self.operation = DELETE_REQUEST
            # Get result sourced id from resultRecord
            self.lis_result_sourcedid = result.resultRecord.\
                sourcedGUID.sourcedId
        except:
            pass

        try:
            result = root.imsx_POXBody.readResultRequest
            self.operation = READ_REQUEST
            # Get result sourced id from resultRecord
            self.lis_result_sourcedid = result.resultRecord.\
                sourcedGUID.sourcedId
        except:
            pass
65251
public static void writeFile(final Document input, final File output) {
        final StreamResult result = new StreamResult(new StringWriter());

        format(new DOMSource(input), result);

        try {
            new FileWriter(output).write(result.getWriter().toString());
        } catch (final IOException ioEx) {
            LOGGER.error("Problem writing XML to file.", ioEx);
        }
    }
648760
def _write_rough_result_xml_to_file(self, xml, filename):
        """"""
        # Write content to temp file first
        error = xml.get('error', None)
        xml.set('error', 'incomplete') # Mark result file as incomplete
        temp_filename = filename + ".tmp"
        with open(temp_filename, 'wb') as file:
            ET.ElementTree(xml).write(file, encoding='utf-8', xml_declaration=True)
        os.rename(temp_filename, filename)
        if error is not None:
            xml.set('error', error)
        else:
            del xml.attrib['error']
1105406
function _storeXMLModifications() {
			if (bHasLocalStorage) {
				localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications));
			}
		}
1136165
@Override
    public final void xmlWriteRawOn(FormattedWriter writer, boolean callbackToItem) throws IOException
    {
        synchronized (_startLock)
        {
            if (_state == MessageStoreState.STATE_STARTED)
            {
                _xmlWriteRawOn(writer, callbackToItem);
            }
            else
            {
                writer.startTag(XML_MESSAGE_STORE);
                writer.indent();
                writer.newLine();
                writer.write(XML_CANNOT_BE_WRITTEN);
                writer.outdent();
                writer.newLine();
                writer.endTag(XML_MESSAGE_STORE);
            }
        }
    }
403519
void xmlWriteOn(FormattedWriter writer) throws IOException 
    {
        writer.newLine();
        writer.startTag(XML_UNSTORED_ITEM_MANAGER);
        writer.indent();
        _list.xmlWriteOn(writer);
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_UNSTORED_ITEM_MANAGER);
    }
294110
public void saveTo(File file) throws IOException{
        FileOutputStream fout = null;
        try{
            fout = new FileOutputStream(file);
            SyntaxDocument xml = new SyntaxDocument(new StreamResult(fout));
            xml.startDocument();
            xml.add(this);
            xml.endDocument();
        }catch(IOException ex){
            throw ex;
        }catch(Exception ex){
            throw new IOException(ex);
        }finally{
            try{
                if(fout!=null)
                    fout.close();
            }catch(IOException ex){
                ex.printStackTrace();
            }
        }
    }
788288
protected function save()
	{
		$xml     = new SimpleXMLElement('<storage/>');
		$content = $this->getContent();
		array_to_xml($content, $xml);
		$this->file->setContent($xml->asXML());
	}
228047
@Override
    public void writeXML(@WillClose Writer out) throws IOException {
        assert project != null;
        bugsPopulated();
        XMLOutput xmlOutput;
        // if (project == null) throw new NullPointerException("No project");


        xmlOutput = new OutputStreamXMLOutput(out);

        writeXML(xmlOutput);
    }
851514
protected function process()
    {
        // Uses the response object by default
        $this->result = $this->getRequest()->getResponse();

        $contentType = $this->result->getContentType();

        if (stripos($contentType, 'xml') === false) {
            throw new \Exception('The Response is not in a valid XML Content Type.');
        }

        $body = trim($this->result->getBody(true));
        $this->result = new EncodingResponse($body);

        $this->handleResponseErrors($this->result);
    }