本文整理汇总了C#中System.Xml.XmlTextReader.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.GetAttribute方法的具体用法?C# System.Xml.XmlTextReader.GetAttribute怎么用?C# System.Xml.XmlTextReader.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了System.Xml.XmlTextReader.GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadSettings
/// <summary>
/// loads a configuration from a xml-file - if there isn't one, use default settings
/// </summary>
public void ReadSettings()
{
bool dirty = false;
Reset();
try
{
System.Xml.XmlTextReader xmlConfigReader = new System.Xml.XmlTextReader("settings.xml");
while (xmlConfigReader.Read())
{
if (xmlConfigReader.NodeType == System.Xml.XmlNodeType.Element)
{
switch (xmlConfigReader.Name)
{
case "display":
fullscreen = Convert.ToBoolean(xmlConfigReader.GetAttribute("fullscreen"));
resolutionX = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionX"));
resolutionY = Convert.ToInt32(xmlConfigReader.GetAttribute("resolutionY"));
// validate resolution
// TODO
/* if (!GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Any(x => x.Format == SurfaceFormat.Color &&
x.Height == resolutionY && x.Width == resolutionX))
{
ChooseStandardResolution();
dirty = true;
} */
break;
}
}
}
xmlConfigReader.Close();
}
catch
{
// error in xml document - write a new one with standard values
try
{
Reset();
dirty = true;
}
catch
{
}
}
// override fullscreen resolutions
if (fullscreen)
{
ResolutionX = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
ResolutionY = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
}
if(dirty)
Save();
}
示例2: GetBuildStage
private string GetBuildStage()
{
if (!controller.SelectedProject.Detail.IsConnected)
{ return string.Empty; }
if (controller.SelectedProject.ProjectState != ProjectState.Building &&
controller.SelectedProject.ProjectState != ProjectState.BrokenAndBuilding)
{ return controller.SelectedProject.Detail.ProjectDescription; }
String currentBuildStage = controller.SelectedProject.Detail.CurrentBuildStage;
if (currentBuildStage == null || currentBuildStage.Length == 0)
{ return string.Empty; }
System.Text.StringBuilder SB = new System.Text.StringBuilder();
System.IO.StringWriter BuildStage = new System.IO.StringWriter(SB);
try
{
System.Xml.XmlTextReader XReader;
System.Xml.XmlDocument XDoc = new System.Xml.XmlDocument();
XDoc.LoadXml(controller.SelectedProject.Detail.CurrentBuildStage);
XReader = new System.Xml.XmlTextReader(XDoc.OuterXml, System.Xml.XmlNodeType.Document, null);
XReader.WhitespaceHandling = System.Xml.WhitespaceHandling.None;
while (XReader.Read())
{
XReader.MoveToContent();
if (XReader.AttributeCount > 0)
{
BuildStage.WriteLine("{0} {1}", XReader.GetAttribute("Time"), XReader.GetAttribute("Data"));
}
}
}
catch
{
BuildStage = new System.IO.StringWriter();
}
return BuildStage.ToString();
}
示例3: listMetadataFormats
public ListMetadataFormats listMetadataFormats(string sidentifier)
{
System.IO.Stream objStream;
ListMetadataFormats objFormat = new ListMetadataFormats();
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
if (sidentifier.Length == 0)
{
prequestURL = baseURL + "?verb=ListMetadataFormats";
}
else
{
prequestURL = baseURL + "?verb=ListMetadataFormats&identifier=" + sidentifier;
}
try
{
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "ListMetadataFormats")
{
while (rd.Read()) // && rd.NodeType != System.Xml.XmlNodeType.EndElement)
{
switch (rd.Name)
{
case "metadataPrefix":
objFormat.metadataPrefix.Add(ParseOAI(ref rd, "metadataPrefix"));
break;
case "schema":
objFormat.schema.Add(ParseOAI(ref rd, "schema"));
break;
case "metadataNamespace":
objFormat.metadataNamespace.Add(ParseOAI(ref rd, "metadataNamespace"));
break;
default:
break;
}
}
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
rd.Close();
return objFormat;
}
示例4: initialize
public static void initialize(Main pMain)
{
m_pMain = pMain;
m_pWebClient = new CGWebClient();
m_pWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(m_pWebClient_DownloadFileCompleted);
m_pWebClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(m_pWebClient_DownloadProgressChanged);
if (!System.IO.File.Exists(@"pak\Files\tile.p000"))
m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
else if (!System.IO.File.Exists(@"pak\World\_test$sample_1.p000"))
m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
else
m_pWebClient.DownloadFile(WEBSITE + "launcher/patch.xml", "patch.xml");
try
{
using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader(Directory.GetCurrentDirectory() + "/patch.xml"))
//using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader( WEBSITE + "files/patch.xml"))
{
int x = 0;
while (pXmlTextReader.ReadToFollowing("PATCHNODE"))
{
x++;
m_pMain.Status = "Interpreting Patch Information " + x + "...";
if (pXmlTextReader.MoveToFirstAttribute())
{
string strFilename = pXmlTextReader.GetAttribute("file").Replace("./", "");
string strCurrDir = System.IO.Directory.GetCurrentDirectory();
try
{
string Dir = Path.GetDirectoryName(strFilename);
if (!Directory.Exists(Dir) && Dir != "")
Directory.CreateDirectory(Dir);
}
catch
{
m_pMain.Status = "Failed to create or read folder info.";
}
//foreach (string strTemp in strFilename.Split('/'))
//{
// if (!strTemp.Contains("."))
// {
// System.IO.Directory.CreateDirectory(strTemp);
// continue;
// }
//}
uint nChecksum = 0;
if (pXmlTextReader.ReadToFollowing("CHECKSUM"))
{
nChecksum = (uint)pXmlTextReader.ReadElementContentAs(typeof(uint), null);
}
try
{
FileInfo FI = new FileInfo(strFilename);
if (strFilename.ToLower() == Path.GetFileName(Application.ExecutablePath).ToLower())
{
FileInfo FI2 = new FileInfo(strFilename + "_");
if (FI2.Exists)
FI2.Delete();
Thread.Sleep(500);
FI.CopyTo(strFilename + "_");
uint crc = getFileCrc(strFilename + "_");
FI2 = new FileInfo(strFilename + "_");
if (FI2.Exists)
FI2.Delete();
if (crc != nChecksum)
{
PatchSelf = true;
m_pUpdateList.Add(strFilename);
}
continue;
}
if (!FI.Exists)
m_pUpdateList.Add(strFilename);
else
{
uint crc = getFileCrc(strFilename);
if (crc != nChecksum)
{
m_pUpdateList.Add(strFilename);
}
}
}
catch (Exception E)
{
if (E.Message.Contains("msvcr71.dll' because it is being used by another process"))
{
//ignore because it's used by .net and gunz needs it... note that this is a possible abuse for exploitation
}
else
{
MessageBox.Show("Some of the files (" + strFilename + ") that need to be patched/edited are currently in use. Make sure SoulHunterZ is closed. If this error persists, restart your computer.", "Fatal Error");
Application.Exit();
}
}
System.IO.Directory.SetCurrentDirectory(strCurrDir);
//.........这里部分代码省略.........
示例5: identify
//=======================================================================
// Sub/Function: identify
// Description: Use this function to return the identifier information
// from an OAI repository.
//
// example:
// OAI objOAI = new OAI("http://memory.loc.gov/cgi-bin/oai2_0");
// Identify objID = new Identify();
//
// objID = objOAI.identify();
// Console.WriteLine("Base URL: " + objID.baseURL);
// Console.WriteLine("Repository: " + objID.repositoryName);
// Console.WriteLine("Deleted Records: " + objID.deletedRecord);
//=======================================================================
public Identify identify()
{
System.IO.Stream objStream;
Identify objID = new Identify();
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
try
{
prequestURL = baseURL + "?verb=Identify";
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "Identify")
{
while (rd.Read() && rd.NodeType != System.Xml.XmlNodeType.EndElement)
{
switch (rd.Name)
{
case "repositoryName":
objID.repositoryName = ParseOAI(ref rd, "repositoryName");
break;
case "baseURL":
objID.baseURL = ParseOAI(ref rd, "baseURL");
break;
case "protocolVersion":
objID.protocolVersion = ParseOAI(ref rd, "protocolVersion");
break;
case "earliestDatestamp":
objID.earliestDatestamp = ParseOAI(ref rd, "earliestDatestamp");
break;
case "deletedRecord":
objID.deletedRecord = ParseOAI(ref rd, "deletedRecord");
break;
case "granularity":
objID.granularity = ParseOAI(ref rd, "granularity");
break;
case "adminEmail":
objID.adminEmail.Add(ParseOAI(ref rd, "adminEmail"));
break;
case "compression":
objID.compression.Add(ParseOAI(ref rd, "compression"));
break;
case "description":
objID.description.Add(ParseOAIContainer(ref rd, "description"));
break;
}
}
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
rd.Close();
return objID;
}
示例6: ListIdentifiers
public ListIdentifier ListIdentifiers(string sPrefix,
string sset,
string sfrom,
string suntil,
ResumptionToken objToken)
{
System.IO.Stream objStream;
ListIdentifier objList = new ListIdentifier();
Identifiers objRecord;
ResumptionToken myToken;
string tmp = "";
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
if (sPrefix.Length == 0)
{
sPrefix = "oai_dc";
}
if (objToken == null)
{
if (sset.Length != 0)
{
sset = "&set=" + sset;
}
if (sfrom.Length != 0)
{
sfrom = "&from=" + sfrom;
}
if (suntil.Length != 0)
{
suntil = "&until=" + suntil;
}
prequestURL = baseURL + "?verb=ListIdentifiers&metadataPrefix=" + sPrefix + sset + sfrom + suntil;
}
else
{
prequestURL = baseURL + "?verb=ListIdentifiers&resumptionToken=" + objToken.resumptionToken;
//This is where we handle the resumptionToken
}
//======================================================
// If you wanted to support additional metadata formats,
// you would just need to have additional handlers.
//======================================================
//Console.Write(sURL);
try
{
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = "badConnection";
error.errorDescription = e.Message + "<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "ListIdentifiers")
{
do
{
if (rd.Name == "header")
{
tmp = rd.ReadOuterXml();
//tmp += ParseOAIContainer(ref rd, "header", true);
//Console.WriteLine("In the Function: " + tmp);
objRecord = new Identifiers(tmp);
objList.record.Add(objRecord);
//return objRecord;
}
else if (rd.Name == "resumptionToken")
{
tmp = rd.ReadOuterXml();
myToken = new ResumptionToken(tmp);
objList.token = myToken;
}
else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()
} while (rd.Name != "ListIdentifiers"); // loop
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
//.........这里部分代码省略.........
示例7: ResumptionToken
public ResumptionToken(string sXML)
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
while (reader.Read())
{
if (reader.Name == "resumptionToken")
{
expirationDate = reader.GetAttribute("expirationDate");
completeListSize = reader.GetAttribute("completeListSize");
cursor = reader.GetAttribute("cursor");
resumptionToken = reader.ReadString();
}
}
}
示例8: GetRecord
public Record GetRecord(string sidentifier, string sPrefix, ref Object objHandler)
{
System.IO.Stream objStream;
Record objRecord;
string tmp = "";
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
if (sPrefix.Length == 0)
{
sPrefix = "oai_dc";
}
prequestURL = baseURL + "?verb=GetRecord&metadataPrefix=" + sPrefix + "&identifier=" + sidentifier;
//======================================================
// If you wanted to support additional metadata formats,
// you would just need to have additional handlers.
//======================================================
try
{
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "GetRecord")
{
do
{
if (rd.Name == "record")
{
tmp = ParseOAIContainer(ref rd, "record");
objRecord = new Record(tmp, ref objHandler);
return objRecord;
}
else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()
} while (rd.Name != "GetRecord"); // loop
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
return null;
}
示例9: ListSets
public ListSet ListSets(ResumptionToken objToken, ref Object objHandler)
{
System.IO.Stream objStream;
OAI_LIST objRecord;
ListSet objList = new ListSet();
ResumptionToken myToken;
string tmp = "";
System.Net.HttpWebRequest wr;
System.Xml.XmlTextReader rd;
if (objToken == null)
{
prequestURL = baseURL + "?verb=ListSets";
}
else
{
prequestURL = baseURL + "?verb=ListSets&resumptionToken=" + objToken.resumptionToken;
//This is where we handle the resumptionToken
}
//======================================================
// If you wanted to support additional metadata formats,
// you would just need to have additional handlers.
//======================================================
try
{
wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL);
wr.UserAgent = cUserAgent;
System.Net.WebResponse response = wr.GetResponse();
objStream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(objStream);
prawXML = reader.ReadToEnd();
reader.Close();
rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null);
}
catch (Exception e)
{
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name == "ListSets")
{
//while (rd.Read())
do
{
if (rd.Name == "set")
{
objRecord = new OAI_LIST(rd.ReadInnerXml(), ref objHandler);
objList.listset.Add(objRecord);
//return objRecord;
}
else if (rd.Name == "resumptionToken")
{
tmp = rd.ReadOuterXml();
myToken = new ResumptionToken(tmp);
objList.token = myToken;
}
else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()
} while (rd.Name != "ListSets"); // loop
}
else if (rd.Name == "error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
rd.Close();
return objList;
}
示例10: OAI_Header
public OAI_Header(string sXML)
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null);
while (reader.Read() && reader.Name != "header") ; // Keep searching until finding header
if (reader.Name == "header")
{
status = reader.GetAttribute("status");
while (reader.Read())
{
switch (reader.Name)
{
case "identifier":
if (identifier.Length == 0) // In case this is the DC indentifier
identifier = reader.ReadString();
break;
case "datestamp":
datestamp = reader.ReadString();
break;
case "setSpec":
setSpec.Add(reader.ReadString());
break;
}
}
}
}
示例11: AVI_XML
static Avi1MinXmlPackage AVI_XML(string extAvidevName, char centerCode)
{
Avi1MinXmlPackage ret=null;
System.Xml.XmlTextReader rd = new System.Xml.XmlTextReader("1min_avi_data.xml");
System.DateTime xmlfiledate;
while (rd.Read())
{
switch(rd.NodeType)
{
case System.Xml.XmlNodeType.Element:
Console.WriteLine(rd.Name);
if (rd.Name == "file_attribute")
{
Console.WriteLine(rd.GetAttribute("time"));
ret = new Avi1MinXmlPackage();
ret.datetime = System.Convert.ToDateTime(rd.GetAttribute("time"));
}
else
if (rd.Name == "avi_data")
{
if (rd.GetAttribute("eqId") != extAvidevName)
{
rd.Skip();
break;
}
Console.WriteLine("\t" + rd.GetAttribute("eqId"));
}
else if (rd.Name == "plateData")
{
Console.WriteLine("\t\t" + rd.GetAttribute("plateNo")+"\t"+rd.GetAttribute("catchTime"));
int catchSec=System.Convert.ToInt32(rd.GetAttribute("catchTime"));
ret.Items.Add(new RemoteInterface.MFCC.AVIPlateData(extAvidevName, ret.datetime.AddSeconds(catchSec), rd.GetAttribute("plateNo")));
}
break;
}
}
return ret;
}
示例12: IsMediumTrustSetInConfig
//Method two: Get is medium trust (get if config is set as medium trust)
private static bool IsMediumTrustSetInConfig()
{
bool result = false;
try
{
string webConfigFile = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, "web.config");
System.Xml.XmlTextReader webConfigReader = new System.Xml.XmlTextReader(new System.IO.StreamReader(webConfigFile));
webConfigReader.ReadToFollowing("trust");
result = webConfigReader.GetAttribute("level") == "Medium";
webConfigReader.Close(); //Close before return
return result;
}
catch
{
return result;
}
}
示例13: ListRecords
//.........这里部分代码省略.........
if (ee.Status == System.Net.WebExceptionStatus.ProtocolError)
{
var response = ee.Response as System.Net.HttpWebResponse;
if (response != null)
{
if ((int)response.StatusCode == 503)
{
string retryafter = response.Headers["Retry-After"];
if (retryafter != null && IsNumeric(retryafter) == true)
{
{
sleepval = System.Convert.ToInt32(retryafter) * 1000;
}
}
}
}
if (fail <= 4)
{
//System.Windows.Forms.MessageBox.Show(sleepval.ToString());
System.Threading.Thread.Sleep(sleepval);
goto Restart;
}
else
{
wr.Abort();
error.errorName = ee.ToString();
error.errorDescription = ee.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
}
}
catch (Exception e)
{
// System.Windows.Forms.MessageBox.Show("2");
if (wr != null)
{
wr.Abort();
}
error.errorName = e.ToString();
error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL;
return null;
}
fail = 0;
while (rd.Read())
{
if (rd.NodeType == System.Xml.XmlNodeType.Element)
{
if (rd.Name == "responseDate")
{
presponseDate = rd.ReadString();
}
else if (rd.Name=="ListRecords")
{
do
{
if (rd.Name=="record")
{
tmp = ParseOAIContainer(ref rd, "record");
objRecord = new Record(tmp,ref objHandler);
objList.record.Add(objRecord);
//return objRecord;
}
else if (rd.Name=="resumptionToken")
{
tmp=rd.ReadOuterXml();
myToken = new ResumptionToken(tmp);
objList.token = myToken;
}
//else if (rd.Name.ToLower() == "OAI-PMH".ToLower())
//{
// break;
//}
else if (rd.EOF == true)
{
error.errorName = "Empty ListRecords Request";
error.errorDescription = "No data was returned in the ListRecords Element. This is likely an error.";
return null;
}
else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml()
} while (rd.Name!="ListRecords"); // loop
}
else if (rd.Name=="error")
{
error.errorName = rd.GetAttribute("code");
error.errorDescription = rd.ReadString();
return null;
}
}
}
return objList;
}
示例14: VerifyAdwaysAccount
private string VerifyAdwaysAccount(string CustomerID, string AdwaysID, string AdwaysEmail)
{
try
{
string url = "http://club.pchome.net/union/icson/checkHashCode.php?code=" + txtPPCode.Text.Trim();
System.Net.WebClient wc = new System.Net.WebClient();
System.IO.Stream stream = wc.OpenRead(url);
System.Xml.XmlReader xmlread = new System.Xml.XmlTextReader(stream);
string ppResult = stream.ToString();
stream.Close();
wc.Dispose();
while (xmlread.Read())
{
if (xmlread.Name.ToUpper().Equals("RESULT"))
{
break;
}
}
string result = xmlread.GetAttribute(0).ToString();
xmlread.Close();
return result;
}
catch
{
return "-1";
}
}
示例15: DoDeserialize
/// <summary>
/// Load options.
/// </summary>
/// <param name="filePath">File name to load options from.</param>
private void DoDeserialize(string filePath)
{
if (System.IO.File.Exists(filePath))
{
global::System.IO.FileStream fileStream = null;
try
{
fileStream = global::System.IO.File.OpenRead(filePath);
if (fileStream.Length > 5)
{
using (global::System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileStream))
{
try
{
reader.MoveToContent();
// read attributes
string valueE = reader.GetAttribute("errorCategoryVisible");
if (valueE != null)
this.ErrorCategoryVisible = Boolean.Parse(valueE);
string valueW = reader.GetAttribute("warningCategoryVisible");
if (valueW != null)
this.WarningCategoryVisible = Boolean.Parse(valueW);
string valueI = reader.GetAttribute("infoCategoryVisible");
if (valueI != null)
this.InfoCategoryVisible = Boolean.Parse(valueI);
string valueF = reader.GetAttribute("filteredCategoryVisible");
if (valueF != null)
this.FilteredCategoryVisible = Boolean.Parse(valueF);
while (reader.Read())
{
switch (reader.NodeType)
{
case System.Xml.XmlNodeType.Element:
{
DeserializeElement(reader, reader.Name);
break;
}
}
}
}
finally
{
fileStream = null;
}
}
}
}
finally
{
if (fileStream != null)
fileStream.Dispose();
}
}
}