Rahul Khanna

Rahul Khanna

  • NA
  • 236
  • 0

Before inserting new element in xml check if exists the valu

Jul 20 2014 2:17 PM
Hi,

I have below a xml file with the below format:

<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Countries>
<country>India</country>
<country>USA</country>
<country>UK</country>
</Countries>
</Root>

string newCountry="UAE"

I want to insert this "UAE" country to the above xml file, before that I want to check whether "UAE" is already exists in the xml. If not exists then only want to insert otherwise no operation. How can I do this?

Answers (2)