Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello I have this xml code

XML
<AriaGostarInformation>
  <MenuInformation>
    <MenuNames Name="1">
      home
    </MenuNames>
    <MenuNames Name="2">
      pages
    </MenuNames>
    <MenuNames Name="3">
      blog
    </MenuNames>
    <MenuNames Name="4">
      gallery
    </MenuNames>
    <MenuNames Name="5">
      about us
    </MenuNames>
    <MenuNames Name="6">
    contact us
    </MenuNames>
    <SubMenuNames parentName="1">
      fgfgfgfgs
    </SubMenuNames>
    <SubMenuNames parentName="3">
    </SubMenuNames>
  </MenuInformation>
</AriaGostarInformation>


and c# code:
C#
public XmlNodeList getXmlNodeList(string XmlNodeName)
{
    XmlDocument doc = new XmlDocument();
    doc.Load(_connection);
    XmlNodeList elemList = doc.GetElementsByTagName(XmlNodeName);
    return elemList;
}

public void updateXmlNodeWithAttribute(string XmlNodeName, string XmlAttributeName, List<string> XmlNodeAttribute, List<string> XmlNodeValue)
{
    XmlDocument xdoc = new XmlDocument();
    xdoc.Load(_connection);
    XmlNodeList xnode = getXmlNodeList(XmlNodeName);

    for (int i = 0; i < XmlNodeAttribute.Count - 1; i++)
    {
        foreach (XmlNode item in xnode)
        {
            if (item.Attributes[XmlAttributeName].Value == XmlNodeAttribute[i].ToString())
            {
                item.InnerText = XmlNodeValue[i].ToString();
            }
        }
    }

    xdoc.Save(_connection);
}


SQL
The getXmlNodeList method return Specified xmlnodelist from XML file and _connection is string xml address

This code does not throw an error, but DOES NOT update the XML node.

Please help me where is error in my code?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900