两个常用的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;
        }
    }

posted @ 2008-10-13 11:19  昕友软件开发  阅读(407)  评论(0编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯