Users Pricing

forum

Home Forums How add value on xml in specified node – MindStick

How add value on xml in specified node

Royce Roy 2236 27 Jan 2014

I need write program on c#, which check, if exist node on xml. If not: insert value. So I have tree path: ./a/d and some line, which I need insert:

<e name="aaa" value="bbb" />

How read and insert value in correct place? This is original xml:

 <?xml version="1.0" encoding="utf-8"?>
    <a>
      <b>
      <c></c>
      </b>
    </a>

After , I need XML:

<?xml version="1.0" encoding="utf-8"?>
    <a>
      <b>
      <c></c>
      </b>
      <d>
        <e name="aaa" value="bbb" />
      </d>
    </a>

So, can you help me with code?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md