In Below XML I need to update Tax tag as per salary
Unable to insert/or replace value in XML data with condition salary tag
| 42000 | 2 |
| 43000 | 3 |
| 52000 | 5 |
Problem XML:
42000
42000
52000
48000
what I need for my problem
42000
2
42000
3
52000
5
48000


Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 12, 2021, 7:15 AM EST
string path = AppDomain.CurrentDomain.BaseDirectory + "\\test001.xml"; XDocument doc = XDocument.Load(path); var nodes = doc.Root.XPathSelectElements("//Employee").ToList(); for (int i = 0; i < nodes.Count; i++) { if (nodes[i].Element("Salary").Value.ToString() == "XYZ") { nodes[i].Element("Tax").Value = "new value"; } } doc.Save(path);Try this code
Avinash Vajpayee71 reputationPosted Nov 12, 2021, 7:55 AM EST
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 12, 2021, 8:30 AM EST
UPDATE user_details SET xml_data.modify('insert 2 into (/user)[1]') WHERE salary = 420000try this code, you shold have xml data has a column for this solution to work
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 13, 2021, 2:47 PM EST