Jump to content
Sign in to follow this  

See if an XML node exists

Recommended Posts

How can I see if a node exists in an xml file?

Here's the code I currently have:

Func 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


$oXmlroot = $XMLobject.documentElement

$LogFile = $FileSystem.OpenTextFile($strTempFileName)

If @error <> 0 Then

TrayTip("Error", "There was an error opening "& $strTempFileName, 10, 3)


$nClearRecs = $oXmlroot.selectNodes("/LaunchPadConfig/eq2")

For $recs In $nClearRecs

If $recs.selectSingleNode("CurrentUser").text = "respart" Then

$xPath = $oXmlroot.selectSingleNode("/LaunchPadConfig/eq2/CurrentUser")







My code keeps bombing on the line below since the 'CurrentUser' node doesn't exist.

If $recs.selectSingleNode("CurrentUser").text = "respart" Then

How can I have my code basically say "If the node 'CurrentUser' doesn't exist, exit the loop."?

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...