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配置文件信息异常"));
相关文档:
(1)XML
XML是The Extensible Markup Language(可扩展标识语言)的简写。目前推荐遵循的是W3C于2000年10月6日发布的XML1.0,参考(www.w3.org/TR/2000/REC-XML-20001006)。和HTML一样,XML同样来源于SGML,但XML是一种能定义其他语言的语。XML最初设计的目的是弥补HTML的不足,以强大的扩展性满足网络信息发布的需要,后 ......
在Button上触摸按下的时候,Button有focused,pressed和default状态,可以使用不同的图片来显示这三种状态。
先定义一个名为btnselector.xml文件,代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/re ......
xml_parse解析xml文件时候,
很有可能不仅仅调用一次character_handler。
所以在获得xml节点的文本信息的时候,要用连接运算".="。
参考 http://jp2.php.net/manual/ro/function.xml-set-character-data-handler.php
ken at positive-edge dot com
30-Jan-2002
01:20
the function handler is called ......
1.如何在javascript访问C#变量
方法一:使用<%=%>
<input id="Button3" type="button" value="js调用c#变量" onclick="return Button3_onclick()" />
function Button3_onclick()
{
alert('我的名字:'+ '<%=name %>'); ......
我们可以使用XML作为数据传送、沟通的格式,Ajax客户端若要发送XML,基本上就是将XML作为字符串,在POST请求时发送,例如:
*HelloAjax.js
view plaincopy to clipboardprint?
var xmlHttp;
function createXMLHttpRequest() {
if (window.XMLHttpRequest) {   ......