Sep
13
Written by:
Steve Gray
9/13/2010 12:39 PM
Task:
Given this XML document:
<?xml version="1.0" encoding="utf-8"?>
<root>
<currentProfile>default</currentProfile>
<profiles>
<profile name="default">
<scriptFolder>C:\myScripts</scriptFolder>
</profile>
<profile name="special">
<scriptFolder>C:\specialScripts</scriptFolder>
</profile>
</profiles>
</root>
We need to get the value of the ‘scriptFolder’ node for the ‘default’ profile.
Here’s the code:
Imports System.Xml
Dim xmldoc As New XmlDocument
xmldoc.Load(Application.StartupPath & "\Profiles.xml")
Dim strQuery As String
strQuery = "root/profiles/profile[@name='default']/scriptFolder"
Dim xnScriptFolder As XmlNode = xmldoc.SelectSingleNode(strQuery)
As always, I welcome your comments!