I know there's a lot of Post about how to read a XML
file, but I do not find any that has XML
with the same structure I have.
I have the following code.
private void LeituraXML()
{
//Criando objeto xml para abrir o arquivo de configuração
XmlDocument doc = new XmlDocument();
//Informando o caminho onde esta salvo o arquivo xml
string cadastro = @"C:\Users\Dell\Documents\Tipo_Documentos.xml";
doc.Load(cadastro);
XmlNodeList nodelist = doc.SelectNodes("data");
foreach (XmlNode node in nodelist)
{
string teste1 = node.SelectSingleNode("tipo").InnerText;
string teste2 = node.SelectSingleNode("metadata").InnerText;
}
}
and with XML
<service>
<name>TiposDocumentaisEMetadados</name>
</service>
<message>
<type>success</type>
<value/>
</message>
<data>
<tipo codigo="7" name="Comprovante de Endereço">
<metadata name="numero_documento" required="false" type="string" max_length="255"/>
<metadata name="protocolo_processo" required="false" type="string" max_length="255"/>
<metadata name="assunto" required="false" type="string" max_length="800"/>
<metadata name="interessado" required="false" type="string" max_length="255"/>
<metadata name="observacao" required="false" type="string" max_length="255"/>
<metadata name="data_documento" required="true" type="date_time"/>
<metadata name="login_autor" required="true" type="string" max_length="50"/>
</tipo>
</data>
I need to add the code and name
of TAGs <tipo>
to the variables and the% tag I just need <metadata>
?