Exemplo n.º 1
0
        public static string OrgReturnNode(string subNodeName, string sNodeName, OleDbDataReader rst)
        {
            XmlDocument doc    = XmlFun.CreateNewDoc("<" + subNodeName + "/>");
            XmlElement  el_row = null;
            XmlElement  elem   = null;

            while (rst.Read()) // 循环获取记录集的值
            {
                el_row = doc.CreateElement(sNodeName);

                for (int i = 0; i < rst.FieldCount; i++)
                {
                    string strFieldName = rst.GetName(i).ToUpper();
                    string sValue       = rst[i].ToString();

                    elem           = doc.CreateElement(strFieldName);
                    elem.InnerText = sValue;

                    el_row.AppendChild(elem);
                }
                doc.DocumentElement.AppendChild(el_row);
            }

            el_row = null;
            elem   = null;
            return(doc.InnerXml);
        }
Exemplo n.º 2
0
        public static string test()
        {
            try
            {
                string      strXML = "<root><a></a></root>";
                XmlDocument doc    = XmlFun.CreateNewDoc(strXML);

                setAttributeValue(doc, "//a", "sv", "1");
                CreateDocNode(doc, "root/a", "a1", "heihei");
                return(doc.InnerXml);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 统一处理标准的业务操作型XML文档,将文档分析称T-SQL封装到DataStorage类中作为一个事务执行
        /// </summary>
        /// <param name="strXML">标准业务操作型XML文档</param>
        /// <returns>标准 XML 返回文档字符串</returns>
        public static string dealWithXml(string strXML)
        {
            /// 创建执行对象
            DataStorage obj_Storage   = new DataStorage();
            ReturnDoc   obj_ReturnDoc = new ReturnDoc();

            try
            {
                XmlDocument obj_Doc = XmlFun.CreateNewDoc(strXML);
                XmlNodeList nodeLst = obj_Doc.SelectNodes("//*[@operation][@operation!='']");

                for (int i = 0; i < nodeLst.Count; i++)
                {
                    XmlElement ele_Temp = (XmlElement)nodeLst.Item(i);
                    //      创建插入数据的XML
                    string str_SQL = SQLAnalyse.analyseXMLSQL(ele_Temp);

                    obj_Storage.addSQL(str_SQL);
                }

                /// 执行
                string str_Return = obj_Storage.runSQL();


                if (!General.empty(str_Return))
                {
                    obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR);
                    obj_ReturnDoc.setFuncErrorInfo(str_Return);
                }
                else
                {
                    obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS);
                }
            }
            catch (Exception e)
            {
                obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR);
                obj_ReturnDoc.setFuncErrorInfo(e.Message);
            }

            return(obj_ReturnDoc.getXml());
        }
Exemplo n.º 4
0
        public static string getAttributValue(string strXML, string nodePath, int i, string svName)
        {
            XmlDocument doc = XmlFun.CreateNewDoc(strXML);

            return(getAttributValue(doc, nodePath, i, svName));
        }
Exemplo n.º 5
0
        public static Boolean setNodeValue(string strXML, string nodePath, int i, string sValue)
        {
            XmlDocument doc = XmlFun.CreateNewDoc(strXML);

            return(setNodeValue(doc, nodePath, i, sValue));
        }