两个常用的Infopath Service读取域值的函数
//设置域值
public static string NavSetValue(XPathNavigator xn, string strXPath,XmlNamespaceManager xnm,string strValue)
{
try
{
if (xn != null)
{
xn.SelectSingleNode(strXPath, xnm).SetValue(strValue);
return xn.Value;
}
else
{
return "";
}
}
catch (Exception ex)
{
throw ex;
}
}
//读域值
public static string GetInnerXML(XPathNavigator xMain, XmlNamespaceManager xnm, string strXPath)
{
try
{
if (xMain != null)
{
System.Xml.XmlNamespaceManager xNameSpace = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
xNameSpace.AddNamespace("my", xnm.LookupNamespace("my").ToString());
System.Xml.XPath.XPathNavigator FieldNavn = xMain.SelectSingleNode(strXPath, xNameSpace);
return FieldNavn.InnerXml;
}
else
{
return "";
}
}
catch (Exception ex)
{
throw ex;
}
}