Получить значение из тега в XML
I need a solution to get the TAG values from an XML Fiscal. I am not referring to the attribute, but to the value between the tags. In the XML below. I need to search and return the value of TAG CFOP which is 13512.
<pre><?xml version="1.0" encoding="UTF-8"?> -<sitProc xmlns="http://www.sites.com" versao="3.00"> -<sit xmlns="http://www.sites.com"> -<infSit versao="3.00" Id="23425234124354676578456356"> -<ide> <cUF>45</cUF> <cCT>246123</cCT> <CFOP>13512</CFOP> <natOp>Service</natOp> <mod>98</mod>
Что я уже пробовал:
string caminho = openFileXml.FileName; this.caminho = caminho; XmlTextReader xmlReader = new XmlTextReader(caminho); while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: lbDados.Items.Add("<" + xmlReader.Name + ">"); txtDados.Text += "<" + xmlReader.Name + ">" + Environment.NewLine; break; case XmlNodeType.Text: lbDados.Items.Add(xmlReader.Value); txtDados.Text += xmlReader.Value + Environment.NewLine; break; case XmlNodeType.EndElement: lbDados.Items.Add("<" + xmlReader.Name + ">"); txtDados.Text += "<" + xmlReader.Name + ">" + Environment.NewLine; break; } }