本文整理匯總了C#中System.Xml.XmlTextReader.ReadStartElement方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadStartElement方法的具體用法?C# XmlTextReader.ReadStartElement怎麽用?C# XmlTextReader.ReadStartElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadStartElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoadPIDSetting_FromXmlTextReader
public void LoadPIDSetting_FromXmlTextReader(ref XmlTextReader xml_reader)
{
this.cycle_time_in_seconds = Double.Parse(xml_reader.ReadElementString("cycle_time_in_seconds"));
xml_reader.ReadStartElement("outer_zone");
this.proportional_band_EachZone[0] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
this.offset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("offset"));
this.reset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("reset"));
this.rate_EachZone[0] = Double.Parse(xml_reader.ReadElementString("rate"));
xml_reader.ReadEndElement();
xml_reader.ReadStartElement("sample_zone");
this.proportional_band_EachZone[1] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
this.offset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("offset"));
this.reset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("reset"));
this.rate_EachZone[1] = Double.Parse(xml_reader.ReadElementString("rate"));
xml_reader.ReadEndElement();
xml_reader.ReadStartElement("inner_zone");
this.proportional_band_EachZone[2] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
this.offset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("offset"));
this.reset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("reset"));
this.rate_EachZone[2] = Double.Parse(xml_reader.ReadElementString("rate"));
xml_reader.ReadEndElement();
}
示例2: Read
public static DatabaseConfiguration Read (string file)
{
DatabaseConfiguration config = new DatabaseConfiguration ();
StreamReader s = new StreamReader (file);
using (s) {
XmlTextReader tr = new XmlTextReader (s);
tr.MoveToContent ();
tr.ReadStartElement ("Configuration");
tr.MoveToContent ();
tr.ReadStartElement ("DisabledAddins");
tr.MoveToContent ();
if (!tr.IsEmptyElement) {
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType == XmlNodeType.Element) {
if (tr.LocalName == "Addin")
config.DisabledAddins.Add (tr.ReadElementString ());
}
else
tr.Skip ();
tr.MoveToContent ();
}
}
}
return config;
}
示例3: Read
public static DatabaseConfiguration Read(string file)
{
DatabaseConfiguration config = new DatabaseConfiguration ();
StreamReader s = new StreamReader (file);
using (s) {
XmlTextReader tr = new XmlTextReader (s);
tr.MoveToContent ();
if (tr.IsEmptyElement)
return config;
tr.ReadStartElement ("Configuration");
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
tr.Skip ();
}
else if (tr.LocalName == "DisabledAddins") {
// For back compatibility
tr.ReadStartElement ();
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
config.addinStatus [tr.ReadElementString ()] = null;
else
tr.Skip ();
tr.MoveToContent ();
}
tr.ReadEndElement ();
}
else if (tr.LocalName == "AddinStatus") {
tr.ReadStartElement ();
tr.MoveToContent ();
while (tr.NodeType != XmlNodeType.EndElement) {
if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
string aid = tr.GetAttribute ("id");
string senabled = tr.GetAttribute ("enabled");
if (senabled.Length == 0 || senabled == "True")
config.addinStatus [aid] = config;
else
config.addinStatus [aid] = null;
}
tr.Skip ();
tr.MoveToContent ();
}
tr.ReadEndElement ();
}
tr.MoveToContent ();
}
}
return config;
}
示例4: GetProjectType
/// <summary>
/// Parses the input stream and return the associated project type. The stream should point to a project file (csproj or vbproj)
/// </summary>
/// <param name="st">The stream</param>
/// <returns>the project type</returns>
public static string GetProjectType(Stream st)
{
XmlTextReader rd = new XmlTextReader(st);
using (rd)
{
rd.ReadStartElement("Project");
rd.ReadToNextSibling("PropertyGroup");
rd.ReadStartElement("PropertyGroup");
rd.ReadToNextSibling("OutputType");
return rd.ReadString();
}
}
示例5: FromXml
private void FromXml(String xmlStream)
{
try
{
StringReader stringReader = new StringReader(xmlStream);
XmlTextReader reader = new XmlTextReader(stringReader);
while (reader.EOF == false)
{
reader.ReadStartElement("ValidationContext");
String generateSummaryResults = reader.ReadElementString("GenerateSummaryResults");
if (generateSummaryResults == "true")
{
_generateSummaryResults = true;
}
String generateDetailedResults = reader.ReadElementString("GenerateDetailedResults");
if (generateDetailedResults == "true")
{
_generateDetailedResults = true;
}
// ...
// EVS Specific Context properties
// ...
reader.ReadElementString("EvsSpecificContext");
reader.ReadEndElement();
}
reader.Close();
}
catch (Exception e)
{
String message = String.Format("Failed to FromXml() DVTK DICOM EVS Validation Context XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message);
throw new Exception(message, e);
}
}
示例6: Deserialize
public override void Deserialize(Node node, string data)
{
TextReader tr = new StringReader(data);
Dictionary<string, object> properties = new Dictionary<string, object>();
using(XmlReader xmlReader = new XmlTextReader(tr))
{
xmlReader.ReadStartElement("root");
do {
if (xmlReader.NodeType == XmlNodeType.Element) {
string name = xmlReader.Name;
if (xmlReader.Read()) {
switch (xmlReader.NodeType) {
case XmlNodeType.Text:
properties.Add(name, xmlReader.ReadContentAs(xmlReader.ValueType, null));
break;
case XmlNodeType.Element:
List<object> objs = new List<object>();
while(xmlReader.Read() && xmlReader.NodeType != XmlNodeType.EndElement) {
if (xmlReader.Name == "item")
objs.Add(xmlReader.ReadElementContentAs(xmlReader.ValueType, null));
}
properties.Add(name, objs.ToArray());
break;
}
}
}
} while(xmlReader.Read());
}
UpdateNode (node, properties);
}
示例7: Execute
public async Task<int> Execute()
{
using (var reader = new StreamReader(FileName, Encode))
{
XmlReader xmlReader = new XmlTextReader(reader);
xmlReader.ReadStartElement();
while (xmlReader.Read())
{
var xdoc = new XmlDocument();
string content = xmlReader.ReadOuterXml();
if (string.IsNullOrEmpty(content))
{
break;
}
xdoc.LoadXml(content);
for (int i = 0; i < xdoc.DocumentElement.ChildNodes.Count; i++)
{
var xele = xdoc.DocumentElement.ChildNodes[i] as XmlElement;
if (i != 0)
{
_logger.InfoLine(",");
}
_logger.InfoLine(xele.InnerText);
}
_logger.InfoLine("");
}
xmlReader.Close();
return 0;
}
}
示例8: PopulateCache
static void PopulateCache(Dictionary<Key, GenericXmlSecurityToken> cache, Stream stream)
{
XmlTextReader reader = new XmlTextReader(stream);
while (reader.IsStartElement("Entry"))
{
reader.ReadStartElement();
Uri target = new Uri(reader.ReadElementString("Target"));
string issuerStr = reader.ReadElementString("Issuer");
Uri issuer = string.IsNullOrEmpty(issuerStr) ? null : new Uri(issuerStr);
reader.ReadStartElement("Token");
reader.ReadStartElement("XML");
XmlDocument doc = new XmlDocument();
XmlElement tokenXml = doc.ReadNode(reader) as XmlElement;
reader.ReadEndElement();
byte[] key = Convert.FromBase64String(reader.ReadElementString("Key"));
reader.ReadElementString("Id");
DateTime validFrom = Convert.ToDateTime(reader.ReadElementString("ValidFrom"));
DateTime validTo = Convert.ToDateTime(reader.ReadElementString("ValidTo"));
WSSecurityTokenSerializer serializer = new WSSecurityTokenSerializer();
reader.ReadStartElement("InternalTokenReference");
SecurityKeyIdentifierClause internalReference = serializer.ReadKeyIdentifierClause(reader);
reader.ReadEndElement();
reader.ReadStartElement("ExternalTokenReference");
SecurityKeyIdentifierClause externalReference = serializer.ReadKeyIdentifierClause(reader);
reader.ReadEndElement();
reader.ReadEndElement(); // token
reader.ReadEndElement(); // entry
List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>();
GenericXmlSecurityToken token = new GenericXmlSecurityToken(tokenXml, new BinarySecretSecurityToken(key), validFrom, validTo, internalReference, externalReference,
new ReadOnlyCollection<IAuthorizationPolicy>(policies));
cache.Add(new Key(target, issuer), token);
}
}
示例9: Deserialize
public static AAInventoryItemBase Deserialize(string serialization)
{
AAInventoryItemBase item = new AAInventoryItemBase();
StringReader sr = new StringReader(serialization);
XmlTextReader xtr = new XmlTextReader(sr);
xtr.ReadStartElement("InventoryItem");
item.Name = xtr.ReadElementString("Name");
item.ID = UUID.Parse(xtr.ReadElementString("ID"));
item.InvType = Convert.ToInt32(xtr.ReadElementString("InvType"));
item.CreatorId = xtr.ReadElementString("CreatorUUID");
item.CreationDate = Convert.ToInt32(xtr.ReadElementString("CreationDate"));
item.Owner = UUID.Parse(xtr.ReadElementString("Owner"));
item.Description = xtr.ReadElementString("Description");
item.AssetType = Convert.ToInt32(xtr.ReadElementString("AssetType"));
item.AssetID = UUID.Parse(xtr.ReadElementString("AssetID"));
item.SaleType = Convert.ToByte(xtr.ReadElementString("SaleType"));
item.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"));
item.BasePermissions = Convert.ToUInt32(xtr.ReadElementString("BasePermissions"));
item.CurrentPermissions = Convert.ToUInt32(xtr.ReadElementString("CurrentPermissions"));
item.EveryOnePermissions = Convert.ToUInt32(xtr.ReadElementString("EveryOnePermissions"));
item.NextPermissions = Convert.ToUInt32(xtr.ReadElementString("NextPermissions"));
item.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"));
item.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"));
item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned"));
xtr.ReadEndElement();
xtr.Close();
sr.Close();
return item;
}
示例10: Load
public static VexObject Load(string fileFullPathAndName)
{
VexObject vo;
string rootFolder = Path.GetDirectoryName(fileFullPathAndName);
string fileNameOnly = Path.GetFileNameWithoutExtension(fileFullPathAndName);
Environment.CurrentDirectory = rootFolder;
string definitionsFolder = "";
string instancesFolder = "";
uint rootId = 0;
vo = new VexObject(fileNameOnly);
FileStream fs = new FileStream(fileFullPathAndName, FileMode.Open);
XmlTextReader r = new XmlTextReader(fs);
r.ReadStartElement("UIL");
while (r.Read())
{
if (r.IsStartElement())
{
switch (r.Name)
{
case "DefinitionsFolder":
if (r.Read())
{
definitionsFolder = r.Value.Trim();
}
break;
case "InstancesFolder":
if (r.Read())
{
instancesFolder = r.Value.Trim();
}
break;
case "RootId":
if (r.Read())
{
rootId = uint.Parse(r.Value.Trim(), NumberStyles.Any);
}
break;
}
}
}
fs.Close();
string defsPath = rootFolder + Path.DirectorySeparatorChar + fileNameOnly + definitionsFolder;
LoadDefinitions(defsPath, vo);
string instsPath = rootFolder + Path.DirectorySeparatorChar + fileNameOnly + instancesFolder;
LoadInstances(instsPath, vo);
vo.Root = (Timeline)vo.Definitions[rootId];
return vo;
}
示例11: Load
public new void Load(XmlTextReader reader)
{
reader.ReadStartElement("Placeable");
_canEnter = (reader.GetAttribute("canEnter", "").Trim() == "1");
_doesWarp = (reader.GetAttribute("doesWarp", "").Trim() == "1");
_name = reader.GetAttribute("name", "").Trim();
base.Load(reader);
reader.ReadEndElement();
}
示例12: Read
public static CharacterInformation Read(XmlTextReader reader)
{
reader.ReadStartElement ("Class");
string name = reader.ReadElementString ("Name");
reader.ReadEndElement();
return new CharacterInformation
{
Class = name
};
}
示例13: Load
void Load(string fileName)
{
// chargement des valeurs des options depuis le fichier Config.xml
try
{
using (XmlTextReader reader = new XmlTextReader(fileName))
{
reader.ReadStartElement("Config");
do
{
if (!reader.IsStartElement()) continue;
string value = reader.ReadString();
switch (reader.Name)
{
case "VLCPath": VLCPath = value; break;
case "DVDLetter": DVDLetter = value; break;
case "VlcPort": VlcPort = value; break;
case "SoundExts": SoundExts = value; break;
case "PictureExts": PictureExts = value; break;
case "VideoExts": VideoExts = value; break;
case "AudioLanguage": AudioLanguage = value; break;
case "SubLanguage": SubLanguage = value; break;
case "ShowVLC": ShowVLC = (value == "1") || (value == System.Boolean.TrueString); break;
case "Transcode":
switch (value.ToUpper())
{
case "MPGA": TranscodeAudio = AudioTranscode.MPGA; break;
case "A52": TranscodeAudio = AudioTranscode.A52; break;
case "PC": TranscodeAudio = AudioTranscode.PC; break;
default: TranscodeAudio = AudioTranscode.None; break;
}
break;
case "StartMinimized": StartMinimized = (value == "1") || (value == System.Boolean.TrueString); break;
case "MinimizeToTray": MinimizeToTray = (value == "1") || (value == System.Boolean.TrueString); break;
case "FFMpegInterlace": FFMpegInterlace = (value == "1") || (value == System.Boolean.TrueString); break;
case "HalfScale": HalfScale = (value == "1") || (value == System.Boolean.TrueString); break;
case "LIRCActive": LIRCActive = (value == "1") || (value == System.Boolean.TrueString); break;
case "TranscodeVB": TranscodeVB = value; break;
case "PCControlAllowed": PCControlAllowed = Convert.ToBoolean(value); break;
case "LessIconsInExplorer": LessIconsInExplorer = Convert.ToBoolean(value); break;
case "BlackBkgnds": BlackBkgnds = Convert.ToBoolean(value); break;
case "TranscodeVideo":
switch (value.ToUpper())
{
case "MPG2": TranscodeVideo = VideoTranscode.MPG2; break;
default: TranscodeVideo = VideoTranscode.None; break;
}
break;
}
} while (reader.Read());
}
}
catch (FileNotFoundException) { }
}
示例14: LoadRules
public static NamingRules LoadRules(string xmlPath)
{
NamingRules namingRules = new NamingRules();
namingRules.rules = new List<NamingRule>();
using (XmlReader reader = new XmlTextReader(xmlPath))
{
reader.ReadStartElement("Rules");
reader.ReadStartElement("GeneralSettings");
reader.ReadStartElement("FilenameRegex");
namingRules.filenameRegex = reader.ReadString();
reader.ReadEndElement();
reader.ReadStartElement("ContextDepth");
namingRules.contextDepth = reader.ReadContentAsInt();
if (namingRules.ContextDepth < 1 || namingRules.ContextDepth > 4)
throw new FormatException("Context Depth must be between 1 and 4");
reader.ReadEndElement();
reader.ReadStartElement("ContextSeparator");
namingRules.contextSeparator = reader.ReadString();
reader.ReadEndElement();
reader.ReadEndElement();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement)
{
System.Diagnostics.Debug.Assert(reader.Name == "Rules");
break;
}
//if (reader.IsStartElement())
// System.Diagnostics.Debug.Assert(reader.Name == "Rule");
reader.ReadStartElement("Rule");
//reader.Read();
reader.ReadStartElement("SearchString");
string regex = reader.ReadString();
reader.ReadEndElement();
reader.ReadStartElement("Replacement");
string replacement = reader.ReadString();
reader.ReadEndElement();
reader.ReadEndElement();
namingRules.rules.Add(new NamingRule(regex, replacement));
}
reader.ReadEndElement();
}
return namingRules;
}
示例15: Deserialize
public void Deserialize(string str)
{
using (TextReader textReader = new StringReader(str))
using (XmlReader xmlReader = new XmlTextReader(textReader))
{
xmlReader.ReadStartElement();
xmlReader.ReadStartElement();
this.Id = new Guid(xmlReader.ReadContentAsString());
xmlReader.ReadEndElement();
xmlReader.ReadStartElement();
this.Value1 = xmlReader.ReadContentAsInt();
xmlReader.ReadEndElement();
xmlReader.ReadStartElement();
this.Value2 = xmlReader.ReadContentAsDateTime();
xmlReader.ReadEndElement();
xmlReader.ReadStartElement();
this.Value3 = xmlReader.ReadContentAsString();
xmlReader.ReadEndElement();
xmlReader.ReadStartElement();
this.Value4 = xmlReader.ReadContentAsDecimal();
xmlReader.ReadEndElement();
xmlReader.ReadEndElement();
}
}