易截截图软件、单文件、免安装、纯绿色、仅160KB

c# 读写XML文件

   用c#给PDA做了一个PC端的通讯程序,需要保存两个参数。用Delphi时,是保存在ini文件中,c#读写XML比较方便,就用xml文件来保存了。
   
 
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// 下载到PDA的TXT文件路径 
/// </summary>
public string strDownFile;
/// <summary>
/// PDA数据文件上传到PC端的文件路径
/// </summary>
public string strUploadFile;
public CXmlClass()
{
//指定XML文件名
XmlFilePath = "config.xml";
//检测XML配置文件是否存在
if (System.IO.File.Exists(XmlFilePath))
return;
CreateDefaultXml();
}
#region " ReadXML() 读取XML配置文件的参数设置,获取下载的TXT文件路径与上传的数据文件路径"
/// <summary>
/// 读取XML配置文件的参数设置,获取下载的TXT文件路径与上传的数据文件路径
/// </summary>
/// <returns></returns>
public bool ReadXML()
{
try
{
XmlDocument xmlDoc=new XmlDocument();
//读取XML配置文件
xmlDoc.Load(XmlFilePath);
//读取XML文件节点
XmlNode rootNode = xmlDoc.SelectSingleNode("austec奥斯泰克").SelectSingleNode("参数设置");
if ( rootNode==null )
throw( new Exception("XML配置文件信息异常"));
//获取XML文件参数设置下的节点值
XmlElement downfile = (XmlElement)(rootNode.SelectSingleNode("downTxtFilePath"));
if (downfile == null)
throw (new Exception("XML配置文件信息异常"));
strDownFile= downfile.InnerText;
XmlElement uploadfile = (XmlElement)(rootNode.SelectSingleNode("uploadfilePath"));
if (uploadfile == null)
throw (new Exception("XML配置文件信息异常"));


相关文档:

WriteXml类(C#)

using System;
using System.Web;
using System.Data;
using System.Text;
using System.Xml;
using System.IO;
namespace Baolee.GeneralMethod
{
 /// <summary>
 /// WriteXml 的摘要说明。
 /// </summary>
 public class WriteXml
 {
  /// <summary>
......

Java对象转换XML文件:XStream+XPP

不需要生成dtd,无用配置,不需要生成辅助类,速度快。这就是xstream+xpp超强黄金组合。
xstream大家都知道啦,XML Pull Parser是一种高速的 解析xml文件的方式,速度要比传统方式快很多(发现pull式解析现在比较流行了)。下面我给出多种使用方法的例子。
1.最简单的使用方法
因为这个太简单,所以我从moogle的blog http: ......

一个简单的xml类,可以解析和生成xml文件数据

<?php
include('xml.php');
$data = XML_unserialize($xml);
?>
$xml即是xml文件的内容,$data是解析出的数组;
<?php
include('xml.php');
$xml = XML_serialize($data);
?>
以上为使用实例,分别解析xml文档和生成xml格式的数据
xml.php源码
<?php
############################### ......

DELPHI TXMLDocument读取XML出现乱码的问题

XML文件
<?xml version="1.0" encoding="utf-8"?>
.......
因为原因很多,所以这个方法不一定能解决问题
XMLDocument1.LoadfromFile('test.XML');
XMLDocument1.Active:=TRUE;
XMLDocument1.Encoding:='gb2312';
memo1.Text:=XMLDocument1.XML.Text; ......

c#中的Ajax上手篇---非同步请求responseXML

我们可以使用XML作为数据传送、沟通的格式,Ajax客户端若要发送XML,基本上就是将XML作为字符串,在POST请求时发送,例如:
*HelloAjax.js
view plaincopy to clipboardprint?
var xmlHttp;  
function createXMLHttpRequest() {  
    if (window.XMLHttpRequest) {   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号