在windows应用程序中使用此行代码可以得到ROWDATA节点
XmlNode xn=xmlDoc.SelectSingleNode("//DATAPACKET/ROWDATA");
可在PDA模式下却无此方法,不知道有没有可以替换的方法?
XmlNode xn=xmlDoc.SelectSingleNode("//DATAPACKET/ROWDATA");
可在PDA模式下却无此方法,不知道有没有可以替换的方法?
解决方案 »
- vs2005 + wince6.0 开发
- c# 如何用listview 显示文件夹的内容,主要是文件有更新实时的在列表更新!
- 求助啊求助
- 如何替换容器的内容
- C#编WINDOWS程序与编wince程序,在语法上或其他方面有什么区别吗?
- SqlDataAdapter对象填充DataSet出错
- 求:在C#中用GRID++报表的方法
- 怎样实现:调用回调函数 捕捉视频数据,保存在内存,然后在PictureBox上显示!!!!!
- 正则匹配字符串
- 关于窗体继承中的事件问题!!!
- 那位大虾用过matlab呀,它有和c#的接口吗?
- DataGrid邦定的数据中某列数据长度比较长,客户想全部显示内容,该怎么办呢???
using System;
using System.Xml;
using System.IO;
using System.Text;namespace BaseStationPDA
{
/// <summary>
/// Summary description for XMLAccess.
/// </summary>
public class XMLAccess
{
public XMLAccess()
{
//
// TODO: Add constructor logic here
//
} public static string reader(string strin)
{
string strout=string.Empty;
StringReader strReader = new StringReader(strin);
XmlTextReader reader = new XmlTextReader(strReader);
// reader.ReadStartElement();
// return XmlConvert.ToString(reader.ReadString());
try
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
if(reader.Name!="CData")
strout+=reader.Name;
while (reader.MoveToNextAttribute()) // Read the attributes.
{
strout+=reader.Name+"="+reader.Value+";";
}
break;
case XmlNodeType.Text: //Display the text in each element.
strout+="="+reader.Value+";";
while (reader.MoveToNextAttribute()) // Read the attributes.
{
strout+=reader.Name+"="+reader.Value+";";
}
break;
case XmlNodeType. EndElement: //Display the end of the element.
//strout+=reader.Name;
break;
}
}
}
catch(IOException ex)
{
strout="";
}
if(strout.Length>3)
strout=strout.Substring(0,strout.Length-1);
return strout;
} public static string write(string strin)
{
string[] strout=strin.Split(';');
StringWriter wr=new StringWriter();
XmlTextWriter writer=new XmlTextWriter(wr);
writer.Formatting=Formatting.Indented;
try
{
//Write an element (this one is the root).
writer.WriteStartElement("CData");
for(int i=0;i<strout.Length;i++)
{
string[] detail=strout[i].ToString().Split('=');
//写节点
// writer.WriteStartElement(detail[0].ToString());
// writer.WriteString(detail[1].ToString());
// writer.WriteEndElement();
//写属性
writer.WriteAttributeString(detail[0].ToString(),detail[1].ToString());
}
//Write the title element.
//Write the close tag for the root element.
writer.WriteEndElement();
}
catch(IOException ex)
{
return ex.Message.ToString();
}
writer.Close(); //Write the XML to file and close the writer.
return wr.ToString();
}
public static bool Save( string strin,string directory)
{
bool flag=false;
string[] strout=strin.Split(';');
FileStream afile=new FileStream(directory,FileMode.OpenOrCreate);
StreamWriter wr=new StreamWriter(afile);
XmlTextWriter writer=new XmlTextWriter(wr);
writer.Formatting=Formatting.Indented;
try
{
//Write an element (this one is the root).
writer.WriteStartElement("CData");
for(int i=0;i<strout.Length;i++)
{
string[] detail=strout[i].ToString().Split('=');
writer.WriteStartElement(detail[0].ToString());
writer.WriteString(detail[1].ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
flag=true;
}
catch (IOException ex)
{
flag=false;
}
writer.Close(); //Write the XML to file and c
return flag;
}
public static bool delete(string directory)
{
FileInfo fileexis=new FileInfo(directory);
if(!fileexis.Exists)
return true;
try
{
File.Delete(directory); }
catch(IOException ex)
{
return false;
}
return true; }
public static string open(string directory)
{
string strout=string.Empty;
FileInfo fileexis=new FileInfo(directory);
if(!fileexis.Exists)
return strout="file not exist";
FileStream afile=new FileStream(directory,FileMode.Open);
StreamReader strReader = new StreamReader(afile);
XmlTextReader reader = new XmlTextReader(strReader);
// reader.ReadStartElement();
// return XmlConvert.ToString(reader.ReadString());
try
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
if(reader.Name!="CData")
strout+=reader.Name;
while (reader.MoveToNextAttribute()) // Read the attributes.
{
strout+=reader.Name+"="+reader.Value+";";
}
break;
case XmlNodeType.Text: //Display the text in each element.
strout+="="+reader.Value+";";
while (reader.MoveToNextAttribute()) // Read the attributes.
{
strout+=reader.Name+"="+reader.Value+";";
}
break;
case XmlNodeType. EndElement: //Display the end of the element.
//strout+=reader.Name;
break;
}
}
strReader.Close();
}
catch(IOException ex)
{
strout=ex.Message.ToString();
}
if(strout.Length>3)
strout=strout.Substring(0,strout.Length-1);
return strout;
} }
}
string usermessage=XMLAccess.open("\\user.xml");
XMLAccess.Save("User="+txtUser.Text.Trim()+";Password="+txtPassword.Text.Trim()+""
+";checkItem= 基站巡检","\\user.xml");
string tstr=XMLAccess.write("type=PdaLoginCheckRequest;userId="+User+";longitude="+GpsLongitude +";latitude="+GpsLatitude+";speed="+GpsSpeed+";password="+password);