Error while trying to get the value in an XML section, in VB.NET

Asked

Viewed 116 times

1

The error happens right when it passes in the first element "Demi".

XML:

<ide>
  <cUF>11</cUF>
  <cNF>855305</cNF>
  <mod>59</mod>
  <nserieSAT>900000980</nserieSAT>
  <nCFe>000225</nCFe>
  <dEmi>20150109</dEmi>
  <hEmi>132824</hEmi>
  <cDV>1</cDV>
  <tpAmb>2</tpAmb>
  <CNPJ>12345678901234</CNPJ>
  <signAC>SGR-SAT SISTEMA DE GESTAO E RETAGUARDA DO SAT</signAC>
  <assinaturaQRCODE>12312</assinaturaQRCODE>
  <numeroCaixa>010</numeroCaixa>
</ide>

Code:

  Dim document = XDocument.Load("C:\MinhaXML.xml") 

        For Each rXML In document.Descendants("ide")
            sData = rXML.Elements("dEmi").value.ToString
            sHora = rXML.Elements("hEmi").Value
            sQRCODE = rXML.Elements("assinaturaQRCODE").Value
        Next

ERROR:

public member 'value' on type '<GetElements>d__11' not  found

1 answer

0


The copilot was understanding that "Document" is only an object but was giving error in .value, to settle I did the following

 Dim document as XDocument = XDocument.Load("C:\MinhaXML.xml") 

Thus my Variable "Document" was assigned with the Class XDocument

Browser other questions tagged

You are not signed in. Login or sign up in order to post.