buymeapc Posted March 9, 2007 Posted March 9, 2007 How can I see if a node exists in an xml file? Here's the code I currently have: CODEFunc EQ2XML() $XMLobject = ObjCreate("MSXML.DOMDocument") $FileSystem = ObjCreate("Scripting.FileSystemObject") $strTempFileName = $EQ2File&"\lpconfig.xml" $file = FileExists($strTempFileName) ;This function removes the user name from the config file to prevent someone from seeing it in the user field ;It does this by searching the xml file (lpconfig.xml) for the word "respart" ;When it finds it, it completely removes the child object from the file, not just the word respart If $file = 1 Then $XMLobject.Load($strTempFileName) $oXmlroot = $XMLobject.documentElement $LogFile = $FileSystem.OpenTextFile($strTempFileName) If @error <> 0 Then TrayTip("Error", "There was an error opening "& $strTempFileName, 10, 3) EndIf $nClearRecs = $oXmlroot.selectNodes("/LaunchPadConfig/eq2") For $recs In $nClearRecs If $recs.selectSingleNode("CurrentUser").text = "respart" Then $xPath = $oXmlroot.selectSingleNode("/LaunchPadConfig/eq2/CurrentUser") $xPath.parentNode.removeChild($xPath) EndIf $XMLobject.save($strTempFileName) Next EndIf EndFunc My code keeps bombing on the line below since the 'CurrentUser' node doesn't exist. CODEIf $recs.selectSingleNode("CurrentUser").text = "respart" Then How can I have my code basically say "If the node 'CurrentUser' doesn't exist, exit the loop."?
Shevilie Posted April 19, 2007 Posted April 19, 2007 What does this return $recs.selectSingleNode("CurrentUser") Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
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