Searching though XML in VB.NET
<p>I am having issues with wrapping my head around how to search though a xml document to get certain values. It's my first time working with XML and I have tried all manner of techniques I've searched through on stackoverflow with the following two being what I think i am closest to a solution with:</p>

<p>'#1</p>

<pre><code>Dim doc As New XmlDocument()
doc.Load(profilePath)
Dim nodelist As XmlNodeList = doc.SelectNodes("serverconfig/collectorconfig")

For Each node As XmlElement In nodelist
    MessageBox.Show(node("clientsslport").InnerText)
Next
</code></pre>

<p>'#2:</p>

<pre><code>Dim aProfile As XmlDocument = New XmlDocument
Dim aProfileNodes As XmlNodeList
Dim aProfileNode As XmlNode

aProfile.Load(profilePath)
aProfileNodes = aProfile.SelectNodes("/clientsslport")
For Each aProfileNode In aProfileNodes
    frmDebug.lstDebug.Items.Add(aProfileNode.Attributes.GetNamedItem("clientsslport").Value.ToString)
    GLOBALDTSERVERS(profileNum).serverFatClientPort = aProfileNode.Attributes.GetNamedItem("clientsslport").Value.ToString
Next
</code></pre>

<p>The goal is to point the function at a XML document, get values from the xml, and then load those values into object's i've created. Here is an example XML file that i've edited down for privacy and length:</p>

<pre><code>&lt;dynatrace version="6.2.4.1057"&gt;
  &lt;serverconfig memento.version="6.2.4.1057"&gt;
    &lt;collectorconfig usetunnel="false" useproxy="false" authstring="" serverport="6698" groupname="" communicationport="8041" proxyport="8080" embedded="true" compress="true" communicationssl="true" useproxyauthentication="false" proxyhost="" proxyusername="" usepreemtiveproxyauth="true" name="Embedded dynaTrace Collector" watchdogtimeout="10" selfmoncollector="false" serveraddress="localhost" tunnel="http://localhost:8033/tunnel"&gt;
      &lt;agentlistenaddressconfig&gt;
        &lt;listenaddress agentport="9998" agentaddress="" /&gt;
      &lt;/agentlistenaddressconfig&gt;
      &lt;loggingconfig append="true" correlationmaxbytes="31457280" console="INFO" level="INFO" maxfiles="5" correlationmaxfiles="2" path="../log/collector/dynaTrace Collector" html="false" maxbytes="10485760" /&gt;
      &lt;buffers agentbuffersize="32768" /&gt;
      &lt;protocoldumps maxnumberdumps="100" /&gt;
    &lt;/collectorconfig&gt;
    &lt;directories&gt;
      &lt;storedsessions path="sessions/stored" /&gt;
      &lt;temp path="temp" /&gt;
      &lt;reports path="reports" /&gt;
    &lt;/directories&gt;
    &lt;settings&gt;
      &lt;collector requirecompression="false" collectoraddress="" collectorport="5001" collectorssladdress="" collectorsslport="5443" allowcollectorconnections="true" collectorauthstring="" requiressl="false" /&gt;
      &lt;client clientssladdress="" clientport="2020" clientsslport="8443" clientaddress="" requiressl="true" /&gt;
      &lt;frontend frontendsslport="2031" frontendaddress="localhost" frontendrequiressl="true" frontendport="2030" /&gt;
      &lt;server tunnelenabled="true" optimizeforthroughput="true" lastvalidedition="DYNATRACE_PRODUCTION" upperdeletiontriggerlimit="153600" collectortunnelenabled="true" continuoussessionrecording="true" lowerdeletiontriggerlimit="5120" collectortunneladdress="" fqdn="&lt;IPADDRESS&gt;" tunneladdress="" id="-1025570809" tunnelport="8023" jmxexportmanagement="false" jmxexportmonitoring="false" autodashboardsupport="true" jmxport="1099" runtimerevision="2" name="&lt;IPADDRESS&gt;" watchdogtimeout="10" collectortunnelport="6608" selfmonitoringenabled="true" agentbasedselfmonitoringenabled="true" hascollector="false" /&gt;
      &lt;purepath maxnodes="10000" /&gt;
      &lt;buffers pathwriter="524288" pathreader="1048576" measurementwriter="32768"&gt;
        &lt;recentlystoredpaths maxsize="250000" maxage="300000" /&gt;
      &lt;/buffers&gt;
      &lt;oopanalyzer port="7788" address="" logpath="../log/analysisserver" /&gt;
      &lt;profilebackups maxbackupfiles="10" /&gt;
    &lt;/settings&gt;
    &lt;loggingconfig append="true" correlationmaxbytes="31457280" console="INFO" level="INFO" maxfiles="5" correlationmaxfiles="2" path="../log/server" html="false" maxbytes="10485760" /&gt;
    &lt;http externalhttpsport="-1" httpport="8080" externalhostname="" webservicesenabled="true" httpsport="8021" webserveraddress="" externalhttpport="-1" webserverenabled="true" webserveraddressssl="" requiressl="false" /&gt;
    &lt;webstart tunnelenabled="false" proxyauthusername="" proxyautodetectionenabled="false" proxyport="-1" tunnelssl="false" proxyenabled="false" tunneladdress="&lt;IPADDRESS&gt;" tunnelport="8023" anonymouswebstartenabled="true" validationtimestamp="0" webstartenabled="true" proxyaddress="" proxyauthenabled="false" /&gt;
      &lt;loggingconfig append="true" correlationmaxbytes="31457280" console="WARNING" level="INFO" maxfiles="5" correlationmaxfiles="2" path="../log" html="false" maxbytes="10485760" /&gt;
      &lt;plugintypeconfig loglevel="INFO" sourcebundlename="com.dynatrace.diagnostics.plugin.SnmpMonitor" bundleversion="6.2.0.1201" name="SNMP Monitor Plugin" active="true" key=
    &lt;webui webuihttpsport="9911" webuienabled="true" /&gt;
  &lt;/serverconfig&gt;
  &lt;environmentdescriptor memento.version="6.2.4.1057"&gt;
    &lt;os arch="amd64" name="Linux" version="2.6.32-504.8.1.el6.x86_64" /&gt;
    &lt;vm vendor="Oracle Corporation" name="Java HotSpot(TM) 64-Bit Server VM" version="24.80-b11" /&gt;
  &lt;/environmentdescriptor&gt;
  &lt;repositoryconfig memento.version="6.2.4.1057" lowduration="-1" highduration="1209600000" deletefromhigh="true" midduration="5184000000" querytimeout="7200"&gt;
    &lt;repository&gt;
      &lt;database name="dynatrace62" dbms="PostgreSQL" /&gt;
      &lt;credential user="&lt;USER&gt;" /&gt;
      &lt;connection port="5432" usessl="false" host="&lt;IP&gt;" ignorewarnnonproduction="true" useurl="false" connectonstartup="true" embededdatapath="repository" url="&lt;IP&gt;" autopurge_measures="true" /&gt;
    &lt;/repository&gt;
  &lt;/repositoryconfig&gt;
&lt;/dynatrace&gt;
</code></pre>

<p>What i'm looking to do is get values like "8443" from "clientsslport" inside /settings/collector or "PostgreSQL" from "dbms" inside /repositoryconfig. I'm loading a lot more values from the full document but once I get an idea of how to get one, I should be able to reproduce it. </p>

<p>Thanks in advance for any help or insights!</p>