Pregunta

I have a xml data where nodes are present like this

<segment>
<country>US</country>
<prop>Supplier</prop>       
</segment>

The scenario is my business entity is strongly bound with this XML. Now we have to rearchitect the system to make it more scalable. The node names in the xml may change in the future.

<prop>Supplier</prop>

may change to

<name>Supplier</name>

So how to write a dynamic C# code to support this feature ?

¿Fue útil?

Solución 2

I have finally written code to fetch the data using XML configuration.

<Properties>
<NodeName>prop<NodeName>
</Properties>

So now I will read this configuration and fetch the data from XML using the node name from Configuration.By This way I can dynamically process my data.

Thanks

Otros consejos

You can add version or parsing engine to your xml, so it can look something like that:

<root>
  <parseEngine type="version2" />
  <!-- Rest of xml -->
</root>

And in C# you you first read this node and then select parsing method.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top