Reading and Xml Data Recovery

Asked

Viewed 26 times

1

I have the following question...

I am reading an Xml, and to get the values of the nodes I use ...

public class Produto {

    [XmlElement("PRODUTO")]
    public string produto;

}

I would like a way to introduce the name of the element "PRODUCT" in a dynamic way, that is, could change the name of the element.

  • Example:
string parametro = "produto";
XmlElement("parametro")]
public string produto;

Note: Remembering that the product string will receive the value that is recovered from the XML element.

I don’t know if you understand, but you better hope so.

  • I couldn’t understand, can you illustrate what you want to do? What’s the point? Do you want the property parameter to point to the product property? That’s it?

  • I have an Nfe XML, and I need to get the data from that Nfe by reading the XML. Currently I recover the XML data using. Xmlelement and pass the tag name to recover the value. However not always the no and the TAG is the same, so I can not use this way pq when the name of the TAG is different from what is referenced in the code, will give error, so I wanted a way to dynamically define the name of the tag to pass as parameter pro Xmlelement, so that this way the tags were always correct.

  • And in the case I used the product example, but in reality I need to recover the value of ICMS, but as there are 33 ICMS codes it gets complicated if it is not dynamic.

No answers

Browser other questions tagged

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