xml操作
protected void Button1_Click(object sender, EventArgs e)
{
//为response(star)节点 和 Cabins(f) cabin节点分别添加个
string Response = "<TargetResponse> <Response mark=\"a\" test=\"E\"> <Cabins> <Cw C=\"L\" N=\"A\" D=\"75\" P=\"850\" K=\"6.5\" /> <Cw C=\"K\" N=\"A\" D=\"80\" P=\"900\" K=\"6.5\" /> </Cabins></Response> <Response mark=\"b\" test=\"E\"> <Cabins> <Cw C=\"H\" N=\"A\" D=\"80\" P=\"900\" K=\"5\" /> <Cw C=\"B\" N=\"A\" D=\"90\" P=\"1020\" K=\"5\" /> <Cw C=\"Y\" N=\"A\" D=\"100\" P=\"1130\" K=\"5\" /> <Cw C=\"F\" N=\"A\" D=\"150\" P=\"1700\" K=\"6.4\" /> </Cabins> </Response></TargetResponse>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(Response);
XmlNodeList xnlist = xmlDoc.SelectSingleNode("TargetResponse").ChildNodes;
foreach (XmlNode xn in xnlist)
{
XmlElement xnResponse = (XmlElement)xn;
XmlNodeList xnCabins = xn.SelectSingleNode("Cabins").ChildNodes;
XmlAttribute attrstart = xmlDoc.CreateAttribute("star");//创建节点
&
相关文档:
使用SAXReader需要导入dom4j-full.jar包。
dom4j是一个Java的XML API,类似于jdom,用来读写XML文件的。dom4j是一个非常非常优秀的Java XML API,具有性能优异、功能强大和极端易用使用的特点,同时它也是一个开放源代码的软件,可以在SourceForge上找到它。
&n ......
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person id="1">
<username >xiaoma</username>
<password>xiaoma</password>
</person>
<person id="2">
<username>manager</username> ......
XML定义:由标记及其所标记的内容构成的文本文件。
XML作用:用来描述数据的结构,有效分离数据的结构和表示,可以作为数据交换的标准格式。
XML特点:1、可以自定义标记,标记名称是对所标记的数据内容含义的抽象,而不是数据的显示格式。
&n ......
有人会问,DTD和Schema都是对XML文档的一种约束,为什么不就选其中之一,而又有Schema呢。因为DTD安全度太低了,也就是说它的约束定义能力不足,无法对XML实例文档做出更细致的语义限制。其实细心的人会发现,在DTD中,只有一个数据类型,就是PCDATA(用在元素中)和CDATA(用在属性中),在里面写日期也行,数字还行,字符 ......
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......