leecole Posted August 16, 2005 Share Posted August 16, 2005 I realize that this is not an Autit problem, but I see many others trying to deal with xml so I post this in the hope that someone will point me in the right direction. A simpified version of the xml file: Settings.xml <Settings> <Property> <Name>FSContrast</Name> <Value>1.000000</Value> </Property> <Property> <Name>TryCC</Name> <Value>1</Value> </Property> <Property> <Name>AllowDivxPro</Name> <Value>0</Value> </Property> </Settings> Attached is the code that is attempting to toggle the TryCC value. It never changes the value, and I realize that I just don't understand enough about using XML. Perhaps someone that is knowledgable will help?toggle.au3 Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits Link to comment Share on other sites More sharing options...
Lazycat Posted August 16, 2005 Share Posted August 16, 2005 I have not xml help under hand, but looks like $oXmlnode2.text is string property and replaceData(0, 1, "0") is not acceptible to it. Why not just assign value to it? If $i Then If $oXmlnode2.text=="1" Then $oXmlnode2.text = "0" ; If it is on then toggle it off Else $oXmlnode2.text = "1" ; It was off so toggle it on EndIf Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
leecole Posted August 16, 2005 Author Share Posted August 16, 2005 I have not xml help under hand, but looks like $oXmlnode2.text is string property and replaceData(0, 1, "0") is not acceptible to it. Why not just assign value to it?If $i Then If $oXmlnode2.text=="1" Then $oXmlnode2.text = "0" ; If it is on then toggle it off Else $oXmlnode2.text = "1" ; It was off so toggle it on EndIf<{POST_SNAPBACK}>That's what I tried first. It doesn't change the value either. Looking at MSDN DOMreference they used replaceData() to change a comment (Another string property), so I figured that it should work for a text value as well. But it doesn't seem to do so. Lee Cole Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits Link to comment Share on other sites More sharing options...
Lazycat Posted August 16, 2005 Share Posted August 16, 2005 Strange, I tried and this works for me. With code below I'm got Settings1.xml with value "0"... Dim $i=0,$y=0 $oXml = ObjCreate("Msxml2.DOMdocument.3.0") ; Rules $oXml.async=0 ;$oXml.Load("C:\Documents and Settings\All Users\Application Data\Snapstream\Beyond TV\Settings.xml") $oXml.Load(@ScriptDir & "\Settings.xml") If @error Then MsgBox(0,"xmltest","load failed! error-" & @error) $oXmlroot = $oXml.documentElement; Define For $oXmlNode In $oXmlroot.childNodes; Select Case $oXmlnode.nodename = "Property" For $oXmlnode2 in $oXmlnode.Childnodes; Go through Property sub entrys Select Case $oXmlnode2.nodename = "Name"; A property entry If $oXmlnode2.text=="TryCC" Then $i=1 Case $oXmlnode2.nodename = "Value"; A property entry If $i Then If $oXmlnode2.text=="1" Then $oXmlnode2.text = "0" ; If it is on then toggle it off Else $oXmlnode2.text = "1" ; It was off so toggle it on EndIf MsgBox(0, "tooogle", "New value is " & $oXmlnode2.text & " rc=" & @error) $i=0 $y=1 ExitLoop EndIf EndSelect if $y Then ExitLoop Next EndSelect Next If $y Then $oXml.Save(@ScriptDir & "\Settings1.xml") Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
leecole Posted August 16, 2005 Author Share Posted August 16, 2005 Strange, I tried and this works for me. With code below I'm got Settings1.xml with value "0"... Dim $i=0,$y=0 $oXml = ObjCreate("Msxml2.DOMdocument.3.0") ; Rules $oXml.async=0 ;$oXml.Load("C:\Documents and Settings\All Users\Application Data\Snapstream\Beyond TV\Settings.xml") $oXml.Load(@ScriptDir & "\Settings.xml") If @error Then MsgBox(0,"xmltest","load failed! error-" & @error) $oXmlroot = $oXml.documentElement; Define For $oXmlNode In $oXmlroot.childNodes; Select Case $oXmlnode.nodename = "Property" For $oXmlnode2 in $oXmlnode.Childnodes; Go through Property sub entrys Select Case $oXmlnode2.nodename = "Name"; A property entry If $oXmlnode2.text=="TryCC" Then $i=1 Case $oXmlnode2.nodename = "Value"; A property entry If $i Then If $oXmlnode2.text=="1" Then $oXmlnode2.text = "0" ; If it is on then toggle it off Else $oXmlnode2.text = "1" ; It was off so toggle it on EndIf MsgBox(0, "tooogle", "New value is " & $oXmlnode2.text & " rc=" & @error) $i=0 $y=1 ExitLoop EndIf EndSelect if $y Then ExitLoop Next EndSelect Next If $y Then $oXml.Save(@ScriptDir & "\Settings1.xml")<{POST_SNAPBACK}>Hey. you are right. Don't know what I had wrong when I tried that before. Thanks...Lee cole Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now