C# Edit XML, I am totally lost -


I have an XML file to load this code which I do not know is complete. This is my code. Public void updateXML (string xmlFile, string selection node, string selectsing node, string little volume, string selected content) {XmlDocument xml = New XmlDocument (); Xml.load (xmlFile); (XML element element xml.SelectNodes (selectNode)) {foreach (Element element in XmlElement element1) {if (element.SelectSingleNode (selectNode) .intertext == selected category) {XmlNode newvalue = xml.CreateElement (newNode); Newvalue.InnerText = "modified"; Element.ReplaceChild (newvalue, element1); Xml.Save (xmlFile); }}}

Below is the method I use at the end, where I set the xmlfile and this is the (UpdateXML method "data.cs", which is called on the repository Is in

  public zero editCategory (string newNode) {string xmlFile = "Category.xml"; string selectNodes = "ArrayOfCategory / category", string selectSingleNode = "// name", string SelectedCategory = "News"; repository.Update (xmlFile, selectNodes, newNode, selectSingleNode, selectedCategory);}  

What I'm unsure about inserting in different nodes, I Here is my XML file that I want to edit.

  & lt ;? xml version = "1.0" encoding = "UTF-8"? & Gt; ; & Lt; ArrayOfCategory xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/ 2001 / XMLSchema" & gt; & lt; ; Category & gt; & lt; Eid & gt; 6b30511d-2cd1-4325-ad73-7b905f76ffc0 & lt; / id & gt; & lt; Name & gt; News & lt; / Name & gt; & Lt; / Category & gt; & Lt; Category & gt; & Lt; Eid & gt; 516401f4 -b45c-46ef-b8f4- 9d05021ae794 & lt; / Id & gt; & Lt; Name & gt; P ods & lt; / Name & gt; & Lt; / Category & gt; & Lt; Category & gt; & Lt; Eid & gt; 0c9cd216-86cf-4a62-884c-1b428150ebac & lt; / Id & gt; & Lt; Name & gt; Legumes & lt; / Name & gt; & Lt; / Category & gt; & Lt; / ArrayOfCategory & gt;  

I really appreciate your help.

After the text "itemprop =" text ">
  if (element.SelectSingleNode (selectNode) .interext == selectedCategory)  

selectNode = "ArrayOfCategory / category"

  selectedCategory = "News";  

So the inner part of the selection will never be "news" because "news"


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -