Sivabalakrishnan
Sivabalakrishnan

Reputation: 515

Preprocessing technique in c#

Let's assume that we have an XML File.

<world>
    <country > 
        <name>INDIA</name>
        <states>#states_count</states> // the place where i need to need to insert.
    </country>
    <country > 
        <name>SRILANKA</name>
        <states>9 states</states>
    </country>
</world>

I have a string in C# which contains

String states_count  = "29 states";

i replaced this by parsing ,travering to the node using XmlDocument and pasting the string to innerxml.

This is not what i need , i need to find "#states_count" token in xml, and replace the "states_count" string using preprocessor technique.

is it possible using preprocessor technique ?

if yes , please help me in this.

Thank you.

Upvotes: 0

Views: 178

Answers (1)

AndrewWhalan
AndrewWhalan

Reputation: 473

Read your XML file in as a string, do a string replace, load the string as XML with xmlDoc.LoadXml() instead of reading the file.

Upvotes: 1

Related Questions