示例#1
0
        public void AddLink(string title, string uri)
        {
            XmlDocument doc = new XmlDataDocument();

            doc.Load("RssLinks.xml");
            XmlNode rootNode = doc.SelectSingleNode("links");

            XmlNode linkNode = doc.CreateElement("link");

            XmlNode titleNode = doc.CreateElement("title");
            XmlText titleText = doc.CreateTextNode(title);

            titleNode.AppendChild(titleText);

            XmlNode uriNode = doc.CreateElement("uri");
            XmlText uriText = doc.CreateTextNode(uri);

            uriNode.AppendChild(uriText);

            XmlNode defaultshowNode = doc.CreateElement("defaultshow");
            XmlText defaultshowText = doc.CreateTextNode("false");

            defaultshowNode.AppendChild(defaultshowText);

            linkNode.AppendChild(titleNode);
            linkNode.AppendChild(uriNode);
            linkNode.AppendChild(defaultshowNode);

            rootNode.AppendChild(linkNode);

            doc.Save("RssLinks.xml");
        }
示例#2
0
        /// <summary>
        /// 添加strNewVariableName进m_Xmldoc
        /// </summary>
        /// <param name="strNewVariableName"></param>
        protected void AddNewNode(string strNewVariableName)
        {
            XmlElement NewVariable = m_XmlDoc.CreateElement("variable");
            XmlElement NewName     = m_XmlDoc.CreateElement("name");
            XmlElement NewTypeId   = m_XmlDoc.CreateElement("typeid");

            XmlText name   = m_XmlDoc.CreateTextNode(strNewVariableName);
            XmlText typeid = m_XmlDoc.CreateTextNode(m_strTypeId);

            NewVariable.AppendChild(NewName);
            NewVariable.AppendChild(NewTypeId);
            NewName.AppendChild(name);
            NewTypeId.AppendChild(typeid);

            m_XmlDoc.DocumentElement.AppendChild(NewVariable);
        }
示例#3
0
        public void CreateXml(DataSet dataset_for_index_doc, DataSet dataset_for_folder, string indexing, string fullPath, string filename, SqlConnection connection, string folderID, string docID)
        {
            string temp_string     = System.IO.Path.GetExtension(filename);
            string output_filename = filename.Replace(temp_string, ".xml");

            string temp_fullpath = string.Format("{0}\\{1}", fullPath, output_filename);

            //String SQLCommand = " select * from obj where parent_id =" + indexing ;

            DataRow[] indexRow = dataset_for_index_doc.Tables[0].Select("DocID = " + docID);

            XmlDataDocument doc            = new XmlDataDocument();
            XmlDeclaration  xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement      root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);
            DataRow[]  r = dataset_for_folder.Tables[0].Select("folderID = " + folderID);
            string     temp_index_name = r[0].ItemArray[0].ToString().Replace(" ", "");
            XmlElement element1        = doc.CreateElement(string.Empty, temp_index_name, string.Empty);

            doc.AppendChild(element1);
            //Create an element representing the first customer record.
            //foreach (DataRow row in ds.Tables[0].Rows)
            //{
            //    string temp_index_name1 = row.ItemArray[3].ToString().Replace(" ", "");
            //    XmlElement element2 = doc.CreateElement(string.Empty, temp_index_name1, string.Empty);
            //    XmlText text1 = doc.CreateTextNode(row.ItemArray[3].ToString());
            //    element2.AppendChild(text1);
            //    element1.AppendChild(element2);
            //}
            foreach (DataRow index in indexRow)
            {
                string     temp_index_name1 = index.ItemArray[4].ToString().Replace(" ", "");
                XmlElement element2         = doc.CreateElement(string.Empty, temp_index_name1, string.Empty);
                XmlText    text1            = doc.CreateTextNode(index.ItemArray[3].ToString());
                element2.AppendChild(text1);
                element1.AppendChild(element2);
            }
            doc.Save(temp_fullpath);
        }