Think you got a mismatch there between the key your referencing (HistoryAge) and the key in the file (HistoryDays) and might have some mal-formed XML there (UI) ... anyways using this xml:

 Code:
<?xml version="1.0"?>
<config version="1.0" serial="15" timestamp="1237010152.7">
	<Lib>
		<Chat>
			<HistoryDays>14</HistoryDays>
		</Chat>
	</Lib>
	<UI/>
</config>


And this script, seems to work ...

 Code:
Break On

$FILENAME = "C:\config.xml"

$XML = LoadXML($FILENAME)

WriteXMLValue($XML, "config/Lib/Chat/HistoryDays", 123)

SaveXML($XML, $FILENAME)

Exit 0

Function LoadXml($filename)
	Dim $, $rootNode
	$loadXml = CreateObject("Microsoft.XMLDOM");	
 	If NOT $loadXml
		Return
 	EndIf
	$= $loadXml.Load($filename)
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 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


-Shawn