1  LINQ TO XML(代码下载)

       准备:新建项目 linq_Ch7控制台程序,新建一个XML文件夹,我们就轻松地学习一下吧

         XDocument         创建XML文档

         XDeclaration       创建XML中的声明

         XElement             创建XML中的元素

         XAttribute            创建XML中元素的属性

         XComment           创建XML中的注释

 

1.1 创建与读取XML文件

           ①创建XML

              代码如下:

  1. 1: #region 创建一个XML文件夹
  1. 2: string dir = Environment.CurrentDirectory + @"/XML";
  1. 3: if (!Directory.Exists(dir))
  1. 4: {
  1. 5: Directory.CreateDirectory(dir);
  1. 6: }
  1. 7: #endregion
  1. 8: string filePath1 = Environment.CurrentDirectory + @"/XML/XML1.xml";
  1. 9: #region 创建一个xml
  1. 10: //创建一个xml文档
  1. 11: XDocument doc1 = new XDocument(
  1. 12: //创建一个声明
  1. 13: new XDeclaration("1.0", "utf-8", "yes"),
  1. 14: new XElement("Products",
  1. 15: new XAttribute("KeyName", "ID"),
  1. 16: new XAttribute("Identity", "true"),
  1. 17: new XAttribute("IdentitySeed", "1"),
  1. 18: new XAttribute("IdentityIncrement", "1"), new XComment("ID是产品表中的主键"),
  1. 19: new XElement("Product", new XAttribute("ID", "1"),
  1. 20: new XElement("ID", "1", new XComment("编号"), new XAttribute("type", "int")),
  1. 21: new XElement("ProductCode", "XYBCNSZYXMN", new XComment("产品编号"), new XAttribute("type", "nvarchar(50)")),
  1. 22: new XElement("ProductName", "相宜本草男士专用洗面奶", new XComment("产品名称"), new XAttribute("type", "nvarchar(50)")),
  1. 23: new XElement("ProductUnitPrice", "39.90", new XComment("产品单价"), new XAttribute("type", "decimal(18,2)")),
  1. 24: new XElement("ProductTypeID", "1", new XComment("产品类型"), new XAttribute("type", "smallint"),
  1. 25: new XAttribute("ForeignTable", "ProductType"),
  1. 26: new XAttribute("ForeignTableColumn", "ID")
  1. 27: ),
  1. 28: new XElement("ProductDescription", "祛痘效果很好", new XComment("产品描述"), new XAttribute("type", "nvarchar(200)"))
  1. 29: )
  1. 30: )
  1. 31: );
  1. 32: doc1.Save(filePath1);
  1. 33: Console.WriteLine("创建成功");
  1. 34: #endregion

效果图:

生成XML文件内容如下:

②读取XML

  1. 1:             #region 读取
  1. 2: XElement doc2 = XElement.Load(filePath1);
  1. 3: Console.WriteLine(doc2.ToString());
  1. 4: #endregion

效果图:

 

1.2 查找基础

     1.2.1 根元素

  1. XDocument doc3 = XDocument.Load(filePath1);
  1. //根元素
  1. Console.WriteLine("根元素:" + doc3.Root.Name);

  1.2.2 查找指定名称的元素

  1. 1: //查找指定名称的元素
  1. 2: IEnumerable<XElement> elements1 = from xml in doc2.Elements("Product")
  1. 3: where xml.Element("ID").Value == "1"
  1. 4: select xml;
  1. 5: foreach (XElement xe in elements1)
  1. 6: {
  1. 7: Console.WriteLine(xe.Name.LocalName + ":" + xe.Attribute("ID").Value);
  1. 8: }

     效果图:

1.2.3 查找指定属性的元素

     我们再添加几个Product

  1. 1: <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  1. 2: <Products KeyName="ID" Identity="true" IdentitySeed="1" IdentityIncrement="1">
  1. 3: <!--ID是产品表中的主键-->
  1. 4: <Product ID="1">
  1. 5: <ID type="int">1<!--编号--></ID>
  1. 6: <ProductCode type="nvarchar(50)">XYBCNSZYXMN<!--产品编号--></ProductCode>
  1. 7: <ProductName type="nvarchar(50)">相宜本草男士专用洗面奶<!--产品名称--></ProductName>
  1. 8: <ProductUnitPrice type="decimal(18,2)">39.90<!--产品单价--></ProductUnitPrice>
  1. 9: <ProductTypeID type="smallint" ForeignTable="ProductType" ForeignTableColumn="ID">1<!--产品类型--></ProductTypeID>
  1. 10: <ProductDescription type="nvarchar(200)">祛痘效果很好<!--产品描述--></ProductDescription>
  1. 11: </Product>
  1. 12: <Product ID="2">
  1. 13: <ID type="int">2<!--编号--></ID>
  1. 14: <ProductCode type="nvarchar(50)">
  1. 15: WP7CXSJ<!--产品编号--></ProductCode>
  1. 16: <ProductName type="nvarchar(50)">
  1. 17: Windows Phone7 程序设计<!--产品名称--></ProductName>
  1. 18: <ProductUnitPrice type="decimal(18,2)">
  1. 19: 99.00<!--产品单价--></ProductUnitPrice>
  1. 20: <ProductTypeID type="smallint" ForeignTable="ProductType" ForeignTableColumn="ID">2<!--产品类型--></ProductTypeID>
  1. 21: <ProductDescription type="nvarchar(200)">
  1. 22: wp7开发必备<!--产品描述--></ProductDescription>
  1. 23: </Product>
  1. 24: </Products>

开始查询:

  1. 1: //3.查找指定属性的元素
  1. 2: var elements2 = from xml in doc2.Elements("Product") //获得所有的Product节点
  1. 3: select new
  1. 4: {
  1. 5: 编号 = xml.Element("ID").Value,
  1. 6: 产品编号 = xml.Element("ProductCode").Value,
  1. 7: 产品名称 = xml.Element("ProductName").Value,
  1. 8: 产品单价 = xml.Element("ProductUnitPrice").Value,
  1. 9: 产品类型ID = xml.Element("ProductTypeID").Value,
  1. 10: 产品描述 = xml.Element("ProductDescription").Value
  1. 11: };
  1. 12: foreach (var item in elements2)
  1. 13: {
  1. 14: Console.WriteLine("产品名称\t"+item.产品名称);
  1. 15: }
  1. 16: string ProductID="1";
  1. 17: //查找指定属性的元素
  1. 18: var elements3=from xml in doc2.Elements("Product")
  1. 19: where xml.Attribute("ID").Value==ProductID
  1. 20: select new
  1. 21: {
  1. 22: 编号 = xml.Element("ID").Value,
  1. 23: 产品编号 = xml.Element("ProductCode").Value,
  1. 24: 产品名称 = xml.Element("ProductName").Value,
  1. 25: 产品单价 = xml.Element("ProductUnitPrice").Value,
  1. 26: 产品类型ID = xml.Element("ProductTypeID").Value,
  1. 27: 产品描述 = xml.Element("ProductDescription").Value
  1. 28: };
  1. 29: foreach (var item in elements3)
  1. 30: {
  1. 31: Console.WriteLine("ID为"+ProductID+"的产品名称为"+item.产品名称);
  1. 32: }

效果图:

在这里,我的第二个ProductName换行显示了,原因是xml文件中,这一个节点的内容是 换行显示的

1.2.4 访问指定元素的所有属性 

          XElement.FirstAttribute:获取此元素的第一个属性

          XElement.NextAttribute:  获取父元素的下一个属性

          代码如下:

  1. 1: //4.访问指定元素的所有属性
  1. 2: XAttribute firstAttr = doc2.FirstAttribute;
  1. 3: //如果第一个不为空,我们继续查找下一个属性
  1. 4: if (firstAttr != null) {
  1. 5: Console.WriteLine(firstAttr.Name.LocalName+":"+firstAttr.Value);
  1. 6: XAttribute nextAttr = firstAttr.NextAttribute;
  1. 7: while (nextAttr!=null)
  1. 8: {
  1. 9: Console.WriteLine(nextAttr.Name.LocalName + ":" + nextAttr.Value);
  1. 10: nextAttr = nextAttr.NextAttribute;
  1. 11: }
  1. 12: }

效果图:

1.2.5 查找XML中指定名称的元素

          XContainer类(XDocument的父类)的Descendants(XName name)

          Descendants方法用于按文档顺序返回此文档或元素的经过筛选的自带元素的集合,集合中只包括具有匹配XName的元素

  1. 1: //5.查找XML中指定名称的元素
  1. 2: IEnumerable<XElement> elements4 = from xml in doc2.Descendants("ProductName")
  1. 3: select xml;
  1. 4: foreach (var item in elements4)
  1. 5: {
  1. 6: Console.WriteLine(item.Name+":"+item.Value);
  1. 7: }

效果图:

1.2.6 遍历指定节点下的所有对象

  1. 1: //6.遍历指定节点下的所有对象
  1. 2: IEnumerable<XNode> nodes = doc2.Elements("Product").Nodes();
  1. 3: foreach (XNode item in nodes)
  1. 4: {
  1. 5: Console.WriteLine(item.ToString());
  1. 6: }

效果图:

1.2.6 使用OfType<T> 筛选返回指定节点下的T

       返回注释XComment

  1. 1: IEnumerable<XComment> cmts = doc2.Elements("Product").Elements("ProductCode").Nodes().OfType<XComment>();
  1. 2: foreach (XComment item in cmts)
  1. 3: {
  1. 4: Console.WriteLine(item.ToString());
  1. 5: }

效果图:

1.2.7 访问指定节点的父元素

  1. 1:  
  1. 2: //7访问指定节点的父元素
  1. 3: string proname = "相宜本草男士专用洗面奶";
  1. 4: XElement elements6 = doc2.Descendants("ProductName").Where(itm => itm.Value == (proname)).First();
  1. 5: //获得它上面的父元素
  1. 6: XElement xe = elements6.Parent;
  1. 7: Console.WriteLine("《"+proname+"》对应的编码为"+xe.Element("ProductCode").Value);

效果图:

1.2.8 按元素名称排序

  1. 1: //8 .排序
  1. 2: var xx = from xml in doc2.Elements("Product")
  1. 3: orderby xml.Element("ProductName").Value
  1. 4: select new
  1. 5: {
  1. 6: 产品名称=xml.Element("ProductName").Value,
  1. 7: 产品单价 = xml.Element("ProductUnitPrice").Value
  1. 8: };
  1. 9: foreach (var item in xx)
  1. 10: {
  1. 11: Console.WriteLine(item.产品名称+":"+item.产品单价+"元");
  1. 12: }

效果图:

1.2.9 使用Ancestors

代码:

  1. 1: //9.Ancestors的使用
  1. 2: IEnumerable<XElement> elements8 = from xml in doc2.Descendants("ProductName")
  1. 3: select xml;
  1. 4: Console.WriteLine("原来的元素");
  1. 5: foreach (XElement item in elements8)
  1. 6: {
  1. 7: Console.WriteLine(item.Name + ":" + item.Value);
  1. 8: }
  1. 9: //显示每个元素的父元素
  1. 10: Console.WriteLine("现在的父元素");
  1. 11: foreach (XElement item in elements8.Ancestors())
  1. 12: {
  1. 13: Console.WriteLine(item.Name + ":" + item.Value);
  1. 14: }

效果图:

返回元素集合中每个元素的所有属性,使用Attributes的使用

继续添加代码:

  1. foreach (XElement item in elements8.Ancestors())
  1. {
  1. Console.WriteLine(item.Name + ":" + item.Value);
  1. }

效果图:

返回节点集合中每个节点的所有下级节点

继续添加代码

  1. 1: //返回节点集合中每个节点的所有下级节点
  1. 2: Console.WriteLine("返回节点集合中每个节点的所有下级节点");
  1. 3: foreach (XNode item in elements8.DescendantNodes())
  1. 4: {
  1. 5: Console.WriteLine(item.ToString());
  1. 6: }

效果图:

 

1.3 操作基础

     1.3.1 添加元素到XML文件中去

  1. 1: //3.1
  1. 2: XElement newe = new XElement("Product", new XAttribute("ID", "3"),
  1. 3: new XElement("ID", "3", new XComment("编号"), new XAttribute("type", "int")),
  1. 4: new XElement("ProductCode", "DBTNT", new XComment("产品编号"), new XAttribute("type", "nvarchar(50)")),
  1. 5: new XElement("ProductName", "大白兔奶糖", new XComment("产品名称"), new XAttribute("type", "nvarchar(50)")),
  1. 6: new XElement("ProductUnitPrice", "19.90", new XComment("产品单价"), new XAttribute("type", "decimal(18,2)")),
  1. 7: new XElement("ProductTypeID", "2", new XComment("产品类型"), new XAttribute("type", "smallint"),
  1. 8: new XAttribute("ForeignTable", "ProductType"),
  1. 9: new XAttribute("ForeignTableColumn", "ID")
  1. 10: ),
  1. 11: new XElement("ProductDescription", "浓浓的奶香", new XComment("产品描述"), new XAttribute("type", "nvarchar(200)"))
  1. 12: );
  1. 13: doc2.Add(newe);
  1. 14: doc2.Save(filePath1);
  1. 15: Console.WriteLine("添加元素成功!");

效果图:

xml文件图:

  1. 1: <?xml version="1.0" encoding="utf-8"?>
  1. 2: <Products KeyName="ID" Identity="true" IdentitySeed="1" IdentityIncrement="1">
  1. 3: <!--ID是产品表中的主键-->
  1. 4: <Product ID="1">
  1. 5: <ID type="int">1<!--编号--></ID>
  1. 6: <ProductCode type="nvarchar(50)">XYBCNSZYXMN<!--产品编号--></ProductCode>
  1. 7: <ProductName type="nvarchar(50)">相宜本草男士专用洗面奶<!--产品名称--></ProductName>
  1. 8: <ProductUnitPrice type="decimal(18,2)">39.90<!--产品单价--></ProductUnitPrice>
  1. 9: <ProductTypeID type="smallint" ForeignTable="ProductType" ForeignTableColumn="ID">1<!--产品类型--></ProductTypeID>
  1. 10: <ProductDescription type="nvarchar(200)">祛痘效果很好<!--产品描述--></ProductDescription>
  1. 11: </Product>
  1. 12: <Product ID="2">
  1. 13: <ID type="int">2<!--编号--></ID>
  1. 14: <ProductCode type="nvarchar(50)">WP7CXSJ<!--产品编号--></ProductCode>
  1. 15: <ProductName type="nvarchar(50)">Windows Phone7 程序设计</ProductName>
  1. 16: <ProductUnitPrice type="decimal(18,2)">99.00<!--产品单价--></ProductUnitPrice>
  1. 17: <ProductTypeID type="smallint" ForeignTable="ProductType" ForeignTableColumn="ID">2<!--产品类型--></ProductTypeID>
  1. 18: <ProductDescription type="nvarchar(200)">wp7开发必备<!--产品描述--></ProductDescription>
  1. 19: </Product>
  1. 20: <Product ID="3">
  1. 21: <ID type="int">3<!--编号--></ID>
  1. 22: <ProductCode type="nvarchar(50)">DBTNT<!--产品编号--></ProductCode>
  1. 23: <ProductName type="nvarchar(50)">大白兔奶糖<!--产品名称--></ProductName>
  1. 24: <ProductUnitPrice type="decimal(18,2)">19.90<!--产品单价--></ProductUnitPrice>
  1. 25: <ProductTypeID type="smallint" ForeignTable="ProductType" ForeignTableColumn="ID">2<!--产品类型--></ProductTypeID>
  1. 26: <ProductDescription type="nvarchar(200)">浓浓的奶香<!--产品描述--></ProductDescription>
  1. 27: </Product>
  1. 28: </Products>

1.3.2 修改XML元素和属性

  1. 1: IEnumerable<XElement> elements9 = from xml in doc2.Elements("Product")
  1. 2: where xml.Element("ID").Value == "1"
  1. 3: && xml.Element("ProductTypeID").Value == "1"
  1. 4: select xml;
  1. 5: if (elements9.Count() > 0) {
  1. 6: XElement one = elements9.FirstOrDefault();
  1. 7: one.SetElementValue("ProductName", "第一个产品");
  1. 8: one.SetAttributeValue("ID", "7");
  1. 9: }
  1. 10: doc2.Save(filePath1);
  1. 11: Console.WriteLine("修改元素属性和节点成功!");

效果图:

修改成功!

1.3.3 替换指定节点下的所有元素

  1. 1: //3.3
  1. 2: IEnumerable<XElement> elements10 = from xml in doc2.Elements("Product")
  1. 3: where xml.Element("ID").Value == "1"
  1. 4: && xml.Element("ProductTypeID").Value == "1"
  1. 5: select xml;
  1. 6: if (elements10.Count() > 0)
  1. 7: {
  1. 8: XElement one = elements10.First();
  1. 9: one.ReplaceAll(
  1. 10: new XAttribute("ID", "1"),
  1. 11: new XElement("ProductName", "相宜本草男士专用洗面奶", new XComment("产品名称"), new XAttribute("type", "nvarchar(50)")),
  1. 12: new XElement("ProductTypeID", "2")
  1. 13: );
  1. 14: }
  1. 15: doc2.Save(filePath1);
  1. 16: Console.WriteLine("替换元素属性和节点成功!");

效果图:

1.3.4 删除XML中的元素

         使用XElement.Remove()方法,可以删除节点

1.3.5 合计XML元素值

        我们先把Product ID=”1”的那个Product,添加一个ProductUnitPrice节点,方便累加

       然后我们写代码

  1. 1: //3.5
  1. 2: IEnumerable<XElement> elements11 = from ee in doc2.Elements("Product")
  1. 3: select ee;
  1. 4: decimal sums = elements11.Sum(i => Convert.ToDecimal(i.Element("ProductUnitPrice").Value));
  1. 5: Console.WriteLine("累加后的产品总价为"+sums);

      效果图:

 

1.4 属性操作

       1.4.1 添加

  1. 1: IEnumerable<XElement> elements12 = from xml in doc2.Elements("Product")
  1. 2: where xml.Attribute("ID").Value == "1"
  1. 3: select xml;
  1. 4: XAttribute xa = new XAttribute("Increaments", "每次增长的值的大小");
  1. 5: if (elements12.Count() > 0) {
  1. 6: XElement xles = elements12.FirstOrDefault();
  1. 7: xles.Add(xa);
  1. 8: }
  1. 9: doc2.Save(filePath1);
  1. 10: Console.WriteLine("添加元素属性成功!");

        效果图:

        XML文件内容:

1.4.2 修改

  1. 1:           if (elements12.Count() > 0)
  1. 2: {
  1. 3: XElement xles = elements12.FirstOrDefault();
  1. 4: xles.Attribute("Increaments").Value="每次增长的值的大小已经被我修改了";
  1. 5: }
  1. 6: doc2.Save(filePath1);
  1. 7: Console.WriteLine("修改元素属性成功!");

    效果图:

       XML文件内容:

       1.4.3 删除,同元素一样,获得后XAttribute后.Remove()就可以删除

       1.4.4 删除一个元素上的所有属性,获得XElement后.RemoveAttributes()就可以删除一个元素上的所有属性

     

 

1.5 其他操作

    1.5.1 添加注释到XMl文件

  1. 1: IEnumerable<XElement> elements13 = from xml in doc2.Elements("Product")
  1. 2: where xml.Attribute("ID").Value == "1"
  1. 3: select xml;
  1. 4: //添加注释到xml文件
  1. 5: if (elements13.Count() > 0) {
  1. 6: XElement xelements = elements13.FirstOrDefault();
  1. 7: XComment comx = new XComment("这是我测试的注释2013年4月13日1:10:28");
  1. 8: xelements.AddFirst(comx);
  1. 9: }
  1. 10: doc2.Save(filePath1);
  1. 11: Console.WriteLine("添加注释到xml成功!");

    XML文件内容如下:

1.5.2添加声明到XML文件中

  1. XDocument doc5 = new XDocument(
  1. new XDeclaration("1.0","utf-8","yes"),
  1. new XElement("People","茗洋芳竹")
  1. );
  1. doc5.Save(Environment.CurrentDirectory+@"\XML\xml2.xml");
  1. Console.WriteLine("添加了一个声明的XML创建成功");

效果图:

1.5.3添加文档类型到XML文件中(XDocumentType)

  1. 1: XDocument doc6 = new XDocument(
  1. 2: new XDocumentType("People",null, "People.dtd",null),
  1. 3: new XElement("People", "茗洋芳竹")
  1. 4: );
  1. 5: doc6.Save(Environment.CurrentDirectory + @"\XML\xml3.xml");
  1. 6: Console.WriteLine("添加了一个文档类型的XML创建成功");

效果图:

1.5.4 给你一个字符串,变成一个XMl对象

  1. 1: string xmlStr = "<Product ID=\"2\"><ID type=\"int\">2<!--编号--></ID><ProductCode type=\"nvarchar(50)\">WP7CXSJ<!--产品编号--></ProductCode>"
  1. 2: +"<ProductName type=\"nvarchar(50)\">Windows Phone7 程序设计</ProductName>"
  1. 3: +" <ProductUnitPrice type=\"decimal(18,2)\">99.00<!--产品单价--></ProductUnitPrice>"
  1. 4: +"<ProductTypeID type=\"smallint\" ForeignTable=\"ProductType\" ForeignTableColumn=\"ID\">2<!--产品类型--></ProductTypeID>"
  1. 5: +"<ProductDescription type=\"nvarchar(200)\">wp7开发必备<!--产品描述--></ProductDescription>"
  1. 6: +"</Product>";
  1. 7: XElement txe = XElement.Parse(xmlStr);
  1. 8: txe.Save(Environment.CurrentDirectory+@"\XML\xml5.xml");

效果图:

1.5.5 使用Linq to XMl 转换XML

这里我直接贴代码了,使用linq to sql取出数据库数据,转换成XElement等对象。例如:

XDocument doc=new  XDocument(

         new XDeclaration(“1.0”,”utf-8”,”yes”),

         new XElement(“Products”,

                  from o in db.Products

                  select new XElement[]{

                      new XElement(“Product”,

                           new XAttribute(“ID”,o.ID),

                           new XElement(“ID”,o.ID),

                           new XElement(“ProductCode”,o.ProductCode),

                           …

                          )

}

聪明的你应该已经看懂了,这里只是一个思路

 

好了,到此为止,恭喜你,Linq to XML 你已经学习完了,谢谢你的学习!

那天有个小孩跟我说LINQ(七)转载的更多相关文章

  1. 那天有个小孩跟我说LINQ(五)转载

    2  LINQ TO SQL(代码下载)      我们以一个简单的销售的业务数据库为例子         表结构很简单:Users(购买者(用户)表),Products(产品信息表),Sales(销 ...

  2. 那天有个小孩跟我说LINQ(六)转载

    2  LINQ TO SQL完结(代码下载)      我们还是接着上次那个简单的销售的业务数据库为例子,打开上次那个例子linq_Ch5 2.1 当数据库中的表建立了主外键 ①根据主键获取子表信息 ...

  3. 那天有个小孩跟我说LINQ(四)转载

    1  LINQ TO SQL(代码下载)       我们以一个酒店管理系统的数据库为例子         表结构很简单:GuestInfo(客人信息表),Room(房间表),RoomType(房间类 ...

  4. 那天有个小孩跟我说LINQ(三)转载

    1  LINQ TO Objects续2(代码下载)      新建项目 linq_Ch3控制台程序    1.1 操作字符串        ①查找字符串中包含的大写字母,字符串是由多个char类型组 ...

  5. 那天有个小孩跟我说LINQ(二)转载

    1  LINQ TO Objects续(代码下载)      新建项目 linq_Ch2控制台程序,新建一个Entity文件夹    1.1 学生成绩查询(练习Join)         有三张表如下 ...

  6. 那天有个小孩跟我说LINQ(一) 转载

    1  LINQ准备(代码下载) 新建项目 linq_Ch1控制台程序,新建一个Entity文件夹     1.1 对象初始化器     在Entity新建一个类Student,代码如下 using S ...

  7. 那天有个小孩跟我说LINQ(八)学会Func

    文章已经迁移到:http://www.ayjs.net/2013/08/68/ 文章已经迁移到:http://www.ayjs.net/2013/08/68/ 文章已经迁移到:http://www.a ...

  8. 那天有个小孩教我WCF[一][2/3]

    接着上次的继续讲吧 我们开始吧 9.创建数据库 use master go --创建库 if exists(select * from sysdatabases where name='NewsDB' ...

  9. 那天有个小孩教我WCF[一][1/3]

    那天有个小孩教我WCF[一][1/3] 既然是小孩系列,当然要有一点基础才能快速掌握,归纳,总结的一个系列,哈哈 前言: 第一篇嘛,不细讲,步步教你创建一个简单SOA案例,对WCF有个基本的认识,我不 ...

随机推荐

  1. ORA-00214: control file 控制文件版本不一致

    故障现象:今日学习oracle控制文件移动和修改,发现本机安装oracle数据库启动时只使用了一个控制文件.如下:SQL> select * from V$controlfile; STATUS ...

  2. linkscrpit

    一 section是什么? 好吧,我们需要解释一下平时编译链接生成的二进制可执行程序(比如说ELF,EXE也行),so或者dll,内核(非压缩的,参加本系列第一节内容.vmlinux),或者ko是怎么 ...

  3. jsp简易文件上传(common.fileupload)

    昨天开始重新架构我的V&View(维视),之前写文章使用的是一个kindediter的插件,挺好用的.最近不知道咋了,出现了些小问题.早在写V&View的时候就想用以下两种方法实现文章 ...

  4. java 小结2 多态问题和容器介绍

    面向对象这个东西,其实我们一直是不是都没有感觉到自己在用,以后我一定要用用.以前学c#时候认真的看过一次,最近一直研究java.随便再看看. 多态问题: 在java中多态分为(1)编译时多态和(2)运 ...

  5. Jquery Ajax的时候 老是返回到 error,是因为json格式不正规的原因

    Jquery Ajax的时候 老是返回到 error,是因为json格式不正规的原因: 怪不得不执行,原来我返回的是{success:true,id:1} 这种不规则的字符串,不是严格的json格式, ...

  6. Worker工作者进程

  7. 关于arm处理器 内存编址模式 与 字节对齐方式 (转)

    转自:http://bavon.bokee.com/5429805.html 在x86+Linux上写的程序,在PC机上运行得很好.可是使用ARM的gcc进行交叉编译,再送到DaVinci目标板上运行 ...

  8. 如何解决Python脚本在Linux和Windows上的格式问题

    python是一种对缩进有严格要求的语言, Python脚本可以使用非常多的工具进行编写,笔者在Linux系统使用JEdit进行Python脚本编写,由于在Linux编写脚本比较痛苦,比如想一眼看出相 ...

  9. [struts2]struts结合ECharts的用法

    <script src="http://echarts.baidu.com/build/dist/echarts-all.js"></script> < ...

  10. http://www.cnblogs.com/xdp-gacl/p/3622275.html

    http://www.cnblogs.com/xdp-gacl/p/3622275.html