usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Linq;usingSystem.Xml.Linq;usingSystem.Xml;namespaceconsoleapplication27{classProgram {Static voidMain (string[] args) { varFolderPath = AppDomain.CurrentDomain.BaseDirectory +".. \\.. \\Mapping"; varFiles =System.IO.Directory.GetFiles (FolderPath); foreach(stringFileinchfiles) { varPath = file;//AppDomain.CurrentDomain.BaseDirectory + ". \\.. \\Mapping\\PosPositionProductMapping.hbm.xml ";XmlDocument doc =NewXmlDocument (); Doc. Load (path); varplist = doc. getElementsByTagName (" Property"); BOOLFind1 =false; BOOLFind2 =false; foreach(XmlNode Iteminchplist) { if(Find1 = =false) Find1= Item. attributes["column"]. Value.tolower (). Contains ("Created_employee_name". ToLower ()); if(Find2 = =false) Find2= Item. attributes["column"]. Value.tolower (). Contains ("created_employee_id". ToLower ()); } varCLS = doc. getElementsByTagName ("class")[0]; if(Find1 = =false) { vare1 = Doc. CreateElement (" Property", Doc. Documentelement.namespaceuri); E1. SetAttribute ("column","Created_employee_name"); E1. SetAttribute ("name","Createdemployeename"); E1. SetAttribute ("Update","false"); Cls. AppendChild (E1); } if(Find2 = =false) { varE2 = Doc. CreateElement (" Property", Doc. Documentelement.namespaceuri); E2. SetAttribute ("column","created_employee_id"); E2. SetAttribute ("name","Createdemployeeid"); E2. SetAttribute ("Update","false"); Cls. AppendChild (E2); } doc. Save (path); } } }}
XML operations (Dynamically add property properties other nodes are the same)