xml的简单操作
在很多情况下, 我们会用到XML,比如说配置文件等.C#提供了XML类.
这里我只是简单的写一下XML文件的生成,解析就不多说了.
第一种方法
DataBase db = DataBaseFactory.CreateDataBase(DataBaseType.MySql, strMysql);
DbCommand command = db.GetSqlStringCommand(strSql);
DataTable dt = db.ExecuteDataSet(command).Tables[0];
//string strFileName = Application.StartupPath + "\\" + "test.xml";
DirectoryInfo file = new DirectoryInfo(strPath);
if (!file.Exists)
{
file.Create();
}
string strFileName = strPath + "\\tech.xml";
XmlDocument oXmlDocument = new XmlDocument();
XmlDeclaration xde;
xde = oXmlDocument.CreateXmlDeclaration("1.0", null, null);
xde.Encoding = "gb2312";
xde.Standalone = "yes";
oXmlDocument.AppendChild(xde);
XmlElement xe = oXmlDocument.CreateElement("Root");
//XmlNode root = oX
相关文档:
转:http://hi.baidu.com/oneshotonekill/blog/item/be68b513f7c929d7f6039e1e.html
Whitespace is not allowed before an XML Processing Instruction (< ? ... ?>). HTMLComponent.Eclipse在编辑mxml的时候提示这样的错误。检查才发现代码中在<? ?>之前存在空格。 ......
得到一个需要处理的XMl
private string GetSaveItem()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<menuCollection/>");
foreach (TreeNode node in trvAccessRight.CheckedNodes)
{
if (node != trvAccess ......
基于dom4j的XML格式转化类
package com.lixi.util;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.dom4j.Document;
import org.do ......
写这篇文章的原因有如下几点:1)C++标准库中没有操作XML的方法,用C++操作XML文件必须熟悉一种函数库,LIBXML2是其中一种很优秀的XML库,而且它同时支持多种编程语言;2)LIBXML2库的Tutorial写得不太好,尤其是编码转换的部分,不适用于中文编码的转换;3)网上的大多数关于Libxml2的介绍仅仅是翻译了自带的资料,没有详细介 ......