views:

51

answers:

3
<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#"&gt;
    <!-- ... 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)

+1  A: 

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
yes, that's exactly it, and how should i read the xml to perform this ? i've never used xquery
MarceloRamires
XmlDocument slideDoc = new XmlDocument(nt);slideDoc.Load("filePath");XmlNode titleNode = slideDoc.SelectSingleNode("//p:sp//p:ph[@type='title' or @type='ctrTitle']", nsManager);
salgo60
@Paulo Santos tem algum contato pra podermos conversar? é bom ter contatos de desenvolvedores =)
MarceloRamires
A: 

If you have .Net 3.5 then use linq see http://stackoverflow.com/questions/594231/how-to-select-a-specific-node-with-linq-to-xml

salgo60
A: 
ds.Tables("infNFe").Rows(0).Item(2)

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

MarceloRamires