Reading a template and creating a new XML file using the read template

1.3k Views Asked by At

I'm attempting to read a XML template, code below, and put this content to a new XML file.

<?xml version="1.0" encoding="utf-8"?>
<Format>
<Name title=""></Name>
<FormatA>
    <Scheme name="A" set="number" get="integer">
        <Sample set="number" get="integer">33</Sample>
    </Scheme>
</FormatA>
<FormatX>
    <Scheme name="A" set="number" get="integer">
        <Sample set="number" get="integer">44</Sample>
    </Scheme>
</FormatX>
</Format>

And will input values and write the title and a value for name. e.g When I enter "Counter" for the title and "Cnt" for the value. It will write

<Name title="Counter">Cnt</Name>

Basically, I'll just copy the contents of the template, put it in the new XML file with the inputted title and value.

Thank you for reading and who will answer my inquiry.

1

There are 1 best solutions below

1
On

Did you tried string.Format?

  1. Create the Template XML file with Place Holders, like this {1}
  2. Call String.Format(XmlContent,"Counter","Cnt")

Hope it helps.