I believe your goal as follows.
- You want to retrieve the text of ICOusing Google Apps Script.
In this case, it is required to use the name space when getChild is used. When this is reflected to your script, it becomes as follows.
Modified script:
function getARES() {
  var url = 'https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?'
      + 'ico=06018025'
      + '&xml=1';
  var response = UrlFetchApp.fetch(url);
  var responseText = response.getContentText(); //.replace(/D:/g,'');
  var document = XmlService.parse(responseText);
  var root = document.getRootElement();
  
  // I modified below script.
  var ns1 = XmlService.getNamespace("/ares/xml_doc/schemas/ares/ares_answer_basic/v_1.0.3");
  var ns2 = XmlService.getNamespace("/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.3");
  var res = root.getChild("Odpoved", ns1).getChild("VBAS", ns2).getChild("ICO", ns2).getText();
  Logger.log(res)
}
- When above script is run, 06018025is retrieved.
- When http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=27074358&xml=1is used as the URL ofUrlFetchApp.fetch,27074358is obtained.
References:
Added:
From your replying of Any idea why var res2 = root.getChild("Odpoved", ns1).getChild("VBAS", ns2).getChild("DIC", ns2).getText(); does not work?, now I noticed that your question had been changed.
In your question, you wanted to retrieve the value of ICO. But in the case for retrieving the value of DIC, it is required to check the structure of XML. Because in your script in your question, the XML from var url = 'https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?' + 'ico=06018025' + '&xml=1'; doesn't include the value of DIC. I think that this is the reason of your issue.
When you want to retrieve the value of DIC from http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=27074358&xml=1, please use the following script.
Modified script:
function getARES() {
  var url = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=27074358&xml=1';  // <--- Modified
  var response = UrlFetchApp.fetch(url);
  var responseText = response.getContentText(); //.replace(/D:/g,'');
  var document = XmlService.parse(responseText);
  var root = document.getRootElement();
  var ns1 = XmlService.getNamespace("/ares/xml_doc/schemas/ares/ares_answer_basic/v_1.0.3");
  var ns2 = XmlService.getNamespace("/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.3");
  var res = root.getChild("Odpoved", ns1).getChild("VBAS", ns2).getChild("DIC", ns2).getText();  // <--- Modified
  Logger.log(res)  // In this case, CZ27074358 is retrieved.
}
Note:
About the name space, these threads might be useful.