0
<enviNFe versao="1.10">
  <idLote>000000000000094</idLote> 
  <NFe>
    <infNFe Id="NFe35090254517628000198550010000000011870030005" versao="1.10">
    <!-- ... content ... -->
    </infNFe>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <!-- ... content ... -->
    </Signature>
  </NFe>
</enviNFe>

I have this XML file, how do i get the ID attribute? this question is not about "how to get attributes in xml's", i've found several solutions, but somehow i can't address to this specific attribute in this specific node.

i can get info inside tables that are within "infNF" and i'm loading it into a dataset and using this code:

ds.Tables(Table).Rows(row)(node)

is there a similar way to do what i want to get THIS attribute ?

(you can answer either in C# or VB.NET)

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Marcelo
  • 3,371
  • 10
  • 45
  • 76

3 Answers3

1

Have you tried XQuery?

 var node = element.SelectSingleNode("//infNFe[@id='...']")

And by the looks of the XML it appears you're dealing with Brazilian NFe, right?


Edited to Add

You can find more about XQuery here.

Once you past the brackets... you'll see it's quite simple.

Paulo Santos
  • 11,285
  • 4
  • 39
  • 65
  • yes, that's exactly it, and how should i read the xml to perform this ? i've never used xquery – Marcelo Jan 18 '10 at 12:05
  • XmlDocument slideDoc = new XmlDocument(nt); slideDoc.Load("filePath"); XmlNode titleNode = slideDoc.SelectSingleNode("//p:sp//p:ph[@type='title' or @type='ctrTitle']", nsManager); – salgo60 Jan 18 '10 at 12:08
  • @Paulo Santos tem algum contato pra podermos conversar? é bom ter contatos de desenvolvedores =) – Marcelo Jan 18 '10 at 12:41
0

If you have .Net 3.5 then use linq see How to select a specific node with LINQ-to-XML

Community
  • 1
  • 1
salgo60
  • 957
  • 5
  • 16
0
ds.Tables("infNFe").Rows(0).Item(2)

That's what i've used, thank you guys!

Marcelo
  • 3,371
  • 10
  • 45
  • 76