小毛驴xml初步试验
XmlDocument xmldoc = new XmlDocument();//创建xml文档对象
XmlNode root;//根节点
xmldoc.Load(Server.MapPath("address.xml"));//加载xml文档
root = xmldoc.DocumentElement;//获取根节点
XmlElement student = xmldoc.CreateElement("student");//创建元素
XmlElement node1 = xmldoc.CreateElement("stuName");
node1.InnerText = stuName.Text.Trim();//给元素内文本赋值
XmlElement node2 = xmldoc.CreateElement("phone");
node2.InnerText = phone.Text.Trim();
XmlElement node3 = xmldoc.CreateElement("qq");
node3.InnerText = qq.Text.Trim();
XmlElement node4 = xmldoc.CreateElement("email");
node4.InnerText = email.Text.Trim();
XmlElement node5 = xmldoc.CreateElement("home");
node5.InnerText = home.Text.Trim();
XmlElement node6 = xmldoc.CreateElement("headImage");
node6.InnerText = headImage.Text.Trim();
XmlElement node7 = xmldoc.CreateElement("work");
node7.InnerText = work.Text.Trim();
student.AppendChild(node1);//将指定节点添加到该节点子节点列表的末尾
student.AppendChild(node2);
student.AppendChild(node3);
student.AppendChild(node4);
相关文档:
上次把数据库访问类共享出来了,几个同事网上感慨了一番,真的没有想到我还保留5年前的代码,我说,代码本来就是应该被阅读和研究的,代码同样具有思想和情节,这就是在一穷二白的情况下的历史和轨迹。配置管理同样也是一位尽职的史官。
总结一下,上次给出的代码 ......
近来自己在做xml的解析器。利用到了cmarkup类,就当做存储吧!有需要的朋友可以瞄几眼。
HTREEITEM itemTemp1,itemTemp2;
CString str1,str2;
char strtemp[100];
static bool result = true;
strtemp[0] = 0;
if (result)
{
xml.FindElem();
}
&nbs ......
一: XML的运用场合
XML语言出现的根本目标在于描述在现实生活中经常出现的有关系的数据。在XML语言中,它允许用户自定义标签。一个标签用于描述一段数据;一个标签可分为开始标签和结束标签,在开始标签和结束标签之间,又可以使用其它标签描述其它数据,以此来实现数据关系的描述。例如:
&nb ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using i_salesDAL;
using i_s ......