Inserting the data:
string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:NewCallByProduct", NamespaceManager).AppendChild())
{
writer.WriteStartElement("NewCallByProductSub", myNamespace);
writer.WriteElementString("ProductName", myNamespace, dr[0].ToString());
writer.WriteElementString("Count", myNamespace, count.ToString());
writer.WriteEndElement();
writer.Close();
}
Delete the data:
foreach (XPathNavigator XNav in MainXnav.Select("/my:myFields/my:NewCallByProduct/my:NewCallByProductSub", NamespaceManager))
{
XPathNavigator xNode = MainXnav.SelectSingleNode("/my:myFields/my:NewCallByProduct/my:NewCallByProductSub/my:ProductName", NamespaceManager);
string Xlocation = xNode.Value;
//string Xlocation = MainXnav.SelectSingleNode("/my:myFields/my:NewCallsByLocationGrp/my:NewCallsByLocationSubGroup/my:LocationName", NamespaceManager).Value;
if (Xlocation == "")
{
XNav.MoveToChild("NewCallByProductSub", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-03-03T17:40:51");
XNav.DeleteSelf();
}
}
No comments:
Post a Comment