Ok. So I want to change the value of "HistoryDays" in the samle XML file below. I tried on example and it just appended a new attribute at the bottom of the file. I htink this one will modify the existig value but I am now getting the "idispatch pointers not allowed in expression" error.

Here is the value i wan to modify:
 Code:
<?xml version="1.0"?>
<config version="1.0" serial="15" timestamp="1237010152.7">
  <Lib>
    <Chat>
      <HistoryDays>14</HistoryDays>
    </Chat>
  </Lib>
<UI>
</config>

Here is the code i'm running. Does this seem right. I'm pretty new at this stuff so any direction is appreciated.

JEff.

 Code:
$filename = "C:config.xml"
$xml = LoadXml($filename)
$= WriteXmlValue($xml, "lib/config/HistoryAge", "500")
SaveXml($xml, $filename)
$xml = 0

Function LoadXml($filename)
	Dim $, $rootNode
	$loadXml = CreateObject("Microsoft.XMLDOM");	
 	If NOT $loadXml
		Return
 	EndIf
	$= $loadXml.Load($filename)
EndFunction
	
Function WriteXmlValue($xml, $path, $value)
	Dim $p, $rootNode, $sectionNode, $parentNode, $childNode
	$sectionNode = $xml.SelectSingleNode($path);
	If NOT $sectionNode
		$parentNode = $xml
		For Each $node In Split($path,"/")
			$p = $p + $node	
		   	$sectionNode = $xml.SelectSingleNode($p)
			If NOT $sectionNode
		     	$sectionNode = $xml.CreateElement($node)
		    		$parentNode = $parentNode.AppendChild($sectionNode)
		   	Else
		   		$parentNode = $sectionNode
		  	EndIf
		  	$p = $p + "/"
	  	Next	
 	EndIf
 	If $sectionNode
		$sectionNode.Text = $value
	EndIf
EndFunction

Function SaveXml($xml, $filename)
	$SaveXml = $xml.Save($filename);
EndFunction
	
Function ReadXmlValue($xml, $key, optional $defaultValue)
	Dim $sectionNode
	$sectionNode = $xml.SelectSingleNode($key);
	If NOT $sectionNode
		$ReadXmlValue = $defaultValue;
	Else
		$ReadXmlValue = $sectionNode.FirstChild.Text;
	EndIf
EndFunction

Function WriteXMLattrib($xml, $Path, $Attr, $Value)
	$SelectionTag = $xml.getElementsByTagName($Path)
	$AttrTag = $SelectionTag.item(0)
	$eu = $AttrTag.SetAttribute($Attr,$Value);
EndFunction

Function RearXMLattrib($xml, $Path, $Attr)
	$SelectionTag = $xml.getElementsByTagName($Path)
	$AttrName = $SelectionTag.item(0)
	$RearXMLattrib =$AttrName.getAttribute($Attr)	
EndFunction	



Edited by Benny69 (2009-03-15 08:52 PM)
Edit Reason: Added Code Tags