1

我们想修改一个xml文件的节点,比如web.config,保存文件后代码很乱。我们使用的代码如下:

   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);

我尝试了很多方法来解决这个问题,比如BOM或者Encoding in xml file head。但是我还没有找到正确的方法。

现在我想知道两件事:

  1. 修改后的文件编码。
  2. 使用其编码修改文件。

谁能帮我?

4

0 回答 0