1

We want to modify the node of an xml file such as web.config and we get messy code after saving the file. The code we use is below:

   set  xmlDocument = CoCreateObject("Msxml2.DOMDocument.4.0");
   if (!IsObject(xmlDocument)) then
      return -1;
   endif;

   xmlDocument.async=FALSE; 
   xmlDocument.setProperty("SelectionLanguage","XPath");
   xmlDocument.load(xmlFileName);
   if(IsObject(xmlDocument)=FALSE) then
      return -1;       
   endif;
   set xmlNode = xmlDocument.selectSingleNode(nodePath);
   if(IsObject(xmlNode)=TRUE) then
   xmlNode.Attributes.getNamedItem("value").nodeValue = value;
   xmlDocument.save(xmlFileName);

I tried to use many ways to resolve this problem, such as BOM or Encoding in xml file head. But I haven't found the right way.

Now I would like to know two things:

  1. the modifed file encoding.
  2. modify the file with its encoding.

who can help me?

Oldskool
  • 34,211
  • 7
  • 53
  • 66

0 Answers0