本文整理汇总了C#中System.Xml.XmlNodeReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeReader.ReadString方法的具体用法?C# XmlNodeReader.ReadString怎么用?C# XmlNodeReader.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNodeReader
的用法示例。
在下文中一共展示了XmlNodeReader.ReadString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGenerator
public virtual NvdlValidatorGenerator CreateGenerator (NvdlValidate validate, string schemaType, NvdlConfig config)
{
this.validate = validate;
this.schema_type = schemaType;
this.config = config;
XmlReader schema = null;
// FIXME: we need a bit more strict check.
if (schemaType.Length < 5 ||
!schemaType.EndsWith ("xml") ||
Char.IsLetter (schemaType, schemaType.Length - 4))
return null;
string schemaUri = validate.SchemaUri;
XmlElement schemaBody = validate.SchemaBody;
if (schemaUri != null) {
if (schemaBody != null)
throw new NvdlCompileException ("Both 'schema' attribute and 'schema' element are specified in a 'validate' element.", validate);
schema = GetSchemaXmlStream (schemaUri, config, validate);
}
else if (validate.SchemaBody != null) {
XmlReader r = new XmlNodeReader (schemaBody);
r.MoveToContent ();
r.Read (); // Skip "schema" element
r.MoveToContent ();
if (r.NodeType == XmlNodeType.Element)
schema = r;
else
schema = GetSchemaXmlStream (r.ReadString (), config, validate);
}
if (schema == null)
return null;
return CreateGenerator (schema, config);
}
示例2: MainApplication_OnLoad
private void MainApplication_OnLoad(object sender, EventArgs e)
{
this.SmtpAccountsList.Items.Clear();
string[] AccountSettings = new string[7];
FileLocation = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Smtp Client\\";
ProgramLocation = Environment.CurrentDirectory;
FileInfo Settings = new FileInfo(FileLocation + "settings.xml");
SetWorkingSet(750000, 300000);
#region Loading Settings from Xml file
FileInfo IfSettingsExist = new FileInfo(FileLocation + "settings.xml");
if (IfSettingsExist.Exists)
{
try
{
XmlDocument DocumentSettings = new XmlDocument();
DocumentSettings.Load(FileLocation + "settings.xml");
XmlNodeReader ReadSettings = new XmlNodeReader(DocumentSettings);
//int current = 1;
while (ReadSettings.Read())
{
switch (ReadSettings.NodeType)
{
case XmlNodeType.EndElement:
if (ReadSettings.Name == "Account")
{
this.SmtpAccountsList.Items.Add(AccountSettings[4] + " <" + AccountSettings[5] + "> --" + AccountSettings[0]);
AccountList.Add(AccountSettings);
AccountSettings = (string[])AccountSettings.Clone();
}
break;
case XmlNodeType.Element:
//Get Account Name:
switch (ReadSettings.Name)
{
case "AccountName":
AccountSettings[0] = ReadSettings.ReadString();
break;
case "Server":
AccountSettings[1] = ReadSettings.ReadString();
break;
case "Port":
AccountSettings[2] = ReadSettings.ReadString();
break;
case "Username":
AccountSettings[3] = ReadSettings.ReadString();
break;
case "Name":
AccountSettings[4] = ReadSettings.ReadString();
break;
case "mailAddress":
AccountSettings[5] = ReadSettings.ReadString();
break;
case "ReplyTo":
AccountSettings[6] = ReadSettings.ReadString();
break;
}
break;
}
}
}
catch (Exception ErrorMessage)
{
MessageBox.Show("An unexpected error happened while loading settings:\n" + ErrorMessage + "\n\nYou are being allowed to enter this application, but not to send any e-mails until this error has been fixed (needs restarting the application)");
}
}
else
{
Directory.CreateDirectory(FileLocation.Remove(FileLocation.Length - 1));
}
#endregion
}
示例3: ParseXMLFile
public static void ParseXMLFile(String file,System.Windows.Forms.ComboBox cb , String[] server)
{
Int32 index = 0;
StringBuilder sb = new StringBuilder();
sb.Append(Application.StartupPath + @"\" + file);
XmlDocument document = new XmlDocument();
try
{
document.Load(sb.ToString());
XmlNodeReader reader = new XmlNodeReader(document);
while (reader.Read() && index <= MAX_EMAIL_ACCOUNTS)
{
if (reader.LocalName.Equals("email"))
{
String s = reader.ReadString().Trim().Replace('"', ' ');
cb.Items.Add(s);
}
if (reader.LocalName.Equals("smtpserver"))
{
String s = reader.ReadString().Trim().Replace('"', ' ');
server[index++] = s;
}
}
}
catch (System.IO.FileNotFoundException)
{
// MessageBox.Show("The XML file must be in the Start Application Directory", "Ez-Manage", MessageBoxButtons.OK, MessageBoxIcon.Error);
throw new System.IO.FileNotFoundException();
}
// default email address
cb.Text = cb.Items[0].ToString();
}
示例4: ReadXML
//ReadXml 完成对Proxy的读取
//FileName 当前xml文件的存放位置////, string ProxyAddress, string ProxyPort
//ProxyAddress 欲添加Proxy的Address
//ProxyPort 欲添加Proxy的Port
public void ReadXML(string FileName)
{
//初始化ListView
this.lvProxy.View = View.Details;
this.lvProxy.Columns.Clear();
ColumnHeader columnHeader = new ColumnHeader();
columnHeader.Text = "Address";
columnHeader.Width = 150;
this.lvProxy.Columns.Add(columnHeader);
columnHeader = new ColumnHeader();
columnHeader.Text = "Port";
columnHeader.Width = 50;
this.lvProxy.Columns.Add(columnHeader);
//初始化XML文档
XmlDocument doc = new XmlDocument();
try
{
//加载XML文档
doc.Load(FileName);
XmlNodeList nodeList = doc.GetElementsByTagName("Connection");
ListViewItem listItem;
foreach (XmlNode xmlNode in nodeList)
{
XmlNodeReader nodeReader = new XmlNodeReader(xmlNode);
listItem = new ListViewItem();
while (nodeReader.Read())
{
if (nodeReader.NodeType == XmlNodeType.Element && nodeReader.Name != "Connection")
{
if (nodeReader.Name.Equals("address"))
{
listItem.Text = nodeReader.ReadString();
}
else
{
listItem.SubItems.Add(nodeReader.ReadString());
}
}
}
lvProxy.Items.Add(listItem);
}
}
catch
{
CreateXmlFile(FileName);
}
}