在windows应用程序中使用此行代码可以得到ROWDATA节点
XmlNode xn=xmlDoc.SelectSingleNode("//DATAPACKET/ROWDATA");
可在PDA模式下却无此方法,不知道有没有可以替换的方法?
XmlNode xn=xmlDoc.SelectSingleNode("//DATAPACKET/ROWDATA");
可在PDA模式下却无此方法,不知道有没有可以替换的方法?
解决方案 »
- 大事不好了,我关不了窗体了,大家快来看看阿
- 谁有 "利用XML实现通用WEB报表打印 "的源代码。
- C# 如何动态加载DLL程序集
- 在线的朋友帮帮忙!
- 救命呀,如何更改控件原有的功能,比如farpoint中按enter进入cell编辑状态中,而我希望按回车跳到下一个cell中,如何实现呀,谢谢谢谢,在
- 为何图像绘制不出来
- 关于Zedgraph的问题
- C#如何提取各国文字的字模
- c#进行usb功率计NRP-Z21采数问题
- 请问:写一个pop3收邮件程序应该用什么控件?
- 那位大虾用过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);