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?
Pravesh Singh
27-Jan-2014It's easy with LINQ to XML