Read xml in VB.net

0

I would like to read the line tag version="1.0.1.0" and store it in a variable in Vb.Net?

<?xml version="1.0" encoding="utf-8"?>
<Feed>
  <Tasks>
    <FileUpdateTask hotswap="false" updateTo="file://d:\tmp\update\AtualizadorAplicacao.exe" localPath="AtualizadorAplicacao.exe">
      <Description>Descricao da nova versao.</Description>
      <Conditions>
        <FileVersionCondition what="below" version="1.0.1.0" />
      </Conditions>
    </FileUpdateTask>
  </Tasks>
</Feed>
    
asked by anonymous 19.06.2018 / 02:30

1 answer

0

Assuming your XML is in the C: \ temp \ VBWpfApp1 \ MyFile.xml file ,
With this code you will be able to read the value of the attribute version :

Dim oXML As New XmlDocument

Dim ArquivoXML As String = "C:\temp\VBWpfApp1\MeuArquivo.xml"

oXML.Load(ArquivoXML)        ' Carrega o arquivo XML

Dim oNo = oXML.SelectSingleNode("/Feed/Tasks/FileUpdateTask/Conditions/FileVersionCondition")
Dim versao = oNo.Attributes.GetNamedItem("version").Value
    
19.06.2018 / 17:39