本文整理汇总了C#中System.Xml.XmlReader.ReadToNextSibling方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadToNextSibling方法的具体用法?C# XmlReader.ReadToNextSibling怎么用?C# XmlReader.ReadToNextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadToNextSibling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractDefinitions
private void ExtractDefinitions(XmlReader reader, ResultFile trx)
{
if (reader.ReadToFollowing("TestDefinitions"))
{
if (reader.ReadToDescendant("UnitTest"))
{
do
{
var testId = Guid.Parse(reader.GetAttribute("id"));
var tempResult = trx.Results.First(result => result.TestId == testId);
tempResult.Storage = reader.GetAttribute("storage");
if (reader.ReadToFollowing("TestMethod"))
{
tempResult.CodeBase = reader.GetAttribute("codeBase");
tempResult.AdapterTypeName = reader.GetAttribute("adapterTypeName");
tempResult.ClassName = reader.GetAttribute("className");
}
reader.ReadToNextSibling("UnitTest");
}
while (reader.ReadToNextSibling("UnitTest"));
}
}
}
示例2: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Udc")
{
return false;
}
if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Tips" || reader.ReadToNextSibling("Tips"))
{
Tips = reader.ReadElementContentAsString();
}
if (reader.Name == "Data" || reader.ReadToNextSibling("Data"))
{
Data = reader.ReadElementContentAsString();
}
if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
{
Data = reader.ReadElementContentAsString();
}
return true;
}
示例3: readItems
private void readItems(XmlReader reader) {
reader.ReadToFollowing ("ItemDatabase");
bool continueReading = reader.ReadToDescendant ("Item");
while (continueReading) {
//Read all information from the .xml-file
reader.ReadToDescendant ("Id");
int id = reader.ReadElementContentAsInt ();
reader.ReadToNextSibling ("Name");
string name = reader.ReadElementContentAsString ();
reader.ReadToNextSibling ("Description");
string desc = reader.ReadElementContentAsString ();
reader.ReadToNextSibling ("Value");
int value = reader.ReadElementContentAsInt ();
reader.ReadToNextSibling ("Type");
string type = reader.ReadElementContentAsString ();
ItemType t = type.StringToType ();
//And add the item to the database
Item i = new Item (name, desc, value, t, id);
//check for attributes and add them to the item
checkForAttributes(reader, i);
//Add the item to the databse and read end element
items.Add(i);
reader.ReadEndElement ();
//Check if there is another item to read
continueReading = reader.ReadToNextSibling ("Item");
}
}
示例4: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Ren" || !reader.IsStartElement())
{
return false;
}
if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Command" || reader.ReadToNextSibling("Command"))
{
Command = reader.ReadElementContentAsString();
}
if (reader.Name == "Remark" || reader.ReadToNextSibling("Remark"))
{
Remark = reader.ReadElementContentAsString();
}
if (reader.Name == "Ren" && reader.NodeType == XmlNodeType.EndElement)
{
reader.ReadEndElement();
}
return true;
}
示例5: checkForAttributes
private void checkForAttributes(XmlReader reader, Item i) {
bool attributePresent = reader.ReadToNextSibling ("Attribute");
int vit = 0, inte = 0, str = 0;
while (attributePresent) {
switch (reader.GetAttribute ("Type")) {
case "Stacksize":
i.maxStackSize = reader.ReadElementContentAsInt ();
Debug.Log ("Set max stacksize of " + i.ItemName + " to " + i.maxStackSize);
break;
case "Vitality":
vit = reader.ReadElementContentAsInt ();
break;
case "Intellect":
inte = reader.ReadElementContentAsInt ();
break;
case "Strength":
str = reader.ReadElementContentAsInt ();
break;
default:
Debug.LogAssertion ("Found an unknown attribute while importing items: " + reader.GetAttribute ("Type"));
break;
}
attributePresent = reader.ReadToNextSibling ("Attribute");
}
//i.AssignAttributes (inte, str, vit);
}
示例6: createPlayer
void createPlayer(XmlReader reader)
{
Vector2 pos = Vector2.Zero;
TextureMap t = new TextureMap();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "position":
{
reader.ReadToDescendant("x");
float x = (float)float.Parse((reader.GetAttribute(0)));
reader.ReadToNextSibling("y");
float y = (float)float.Parse((reader.GetAttribute(0)));
pos = new Vector2(x, y);
}
break;
default:
int o = 0;//fer teh deboog
break;
}
}
}
Player p = new Player(pos, t);
}
示例7: ParseBlock
private void ParseBlock(ref List<MemoryBlock> list, ref XmlReader reader)
{
MemoryBlock MemBlock = new MemoryBlock();
reader.ReadToFollowing("m_block_base_addr");
MemBlock.BlockAddress = (UInt64)reader.ReadElementContentAs(typeof(UInt64), null);
reader.ReadToNextSibling("protection");
MemBlock.BlockProtection = (UInt32)reader.ReadElementContentAs(typeof(UInt32), null);
reader.ReadToNextSibling("m_size");
MemBlock.BlockSize = (UInt64)reader.ReadElementContentAs(typeof(UInt64), null);
reader.ReadToNextSibling("m_storage_type");
MemBlock.BlockStorageType = (UInt32)reader.ReadElementContentAs(typeof(UInt32), null);
reader.ReadToNextSibling("m_is_shared");
MemBlock.IsShared = (Boolean)reader.ReadElementContentAs(typeof(Boolean), null);
reader.ReadToNextSibling("m_map_file_name");
MemBlock.MappedFileName = (String)reader.ReadElementContentAs(typeof(String), null);
list.Add(MemBlock);
}
示例8: FromXmlReader
public string FromXmlReader (XmlReader reader)
{
if (!reader.ReadToDescendant ("head"))
return null;
if (!reader.ReadToNextSibling ("body"))
return null;
return reader.ReadInnerXml ();
}
示例9: ReadXml
//Attempt to read batch.xml to load previous settings
//If anything goes wrong, just start without any preloaded settings
public void ReadXml(XmlReader reader)
{
try
{
FileDescs = new Dictionary<string, FbxFileDesc>();
reader.ReadToFollowing("BatchConversion");
reader.ReadToDescendant("Output");
OutputDir = reader.ReadElementContentAsString();
while (reader.LocalName == "FbxFile")
{
var newFile = new FbxFileDesc();
reader.ReadToDescendant("Filename");
var newFilename = reader.ReadElementContentAsString();
if (reader.LocalName != "CollisionGeneration")
reader.ReadToNextSibling("CollisionGeneration");
newFile.CollisionType = reader.ReadElementContentAsString();
while (reader.LocalName == "AnimClip")
{
var newClip = new AnimationClipDesc();
reader.ReadToDescendant("Name");
var newClipName = reader.ReadElementContentAsString();
if (reader.LocalName != "Keyframes")
reader.ReadToNextSibling("Keyframes");
newClip.BeginFrame = double.Parse(reader.GetAttribute("Begin"));
newClip.EndFrame = double.Parse(reader.GetAttribute("End"));
newClip.Fps = double.Parse(reader.GetAttribute("FPS"));
reader.Read();
reader.ReadEndElement();
newFile.AnimationClips.Add(newClipName, newClip);
}
reader.ReadEndElement();
FileDescs.Add(newFilename, newFile);
}
}
catch (Exception)
{
MessageBox.Show(ParentWindow, "Unable to read batch.xml, starting with a clean slate...",
"Error", MessageBoxButton.OK,
MessageBoxImage.Error);
FileDescs = new Dictionary<string, FbxFileDesc>();
OutputDir = "";
}
}
示例10: ReadToNextSibling
// workaround for possible xml reader bug. See http://support.microsoft.com/kb/906724
protected static bool ReadToNextSibling(XmlReader r, string name)
{
if (r.ReadState == ReadState.Initial)
{
r.Read();
if (r.IsStartElement(name))
return true;
}
return r.ReadToNextSibling(name);
}
示例11: ReadXml
public void ReadXml(XmlReader reader)
{
do
{
reader.ReadStartElement("LogProperty");
LogDetailInfo logDetail = new LogDetailInfo();
logDetail.ReadXml(reader);
this.Add(logDetail);
} while (reader.ReadToNextSibling("LogProperty"));
}
示例12: ReadFrom
public static List<SAMAlignedItem> ReadFrom(XmlReader source)
{
var result = new List<SAMAlignedItem>();
source.ReadToFollowing("queries");
if (source.ReadToDescendant("query"))
{
do
{
var query = new SAMAlignedItem();
result.Add(query);
query.Qname = source.GetAttribute("name");
query.Sequence = source.GetAttribute("sequence");
query.QueryCount = int.Parse(source.GetAttribute("count"));
query.Sample = source.GetAttribute("sample");
if (source.ReadToDescendant("location"))
{
do
{
var loc = new SAMAlignedLocation(query);
loc.Seqname = source.GetAttribute("seqname");
loc.Start = long.Parse(source.GetAttribute("start"));
loc.End = long.Parse(source.GetAttribute("end"));
loc.Strand = source.GetAttribute("strand")[0];
loc.Cigar = source.GetAttribute("cigar");
loc.AlignmentScore = int.Parse(source.GetAttribute("score"));
loc.MismatchPositions = source.GetAttribute("mdz");
loc.NumberOfMismatch = int.Parse(source.GetAttribute("nmi"));
var nnmpattr = source.GetAttribute("nnpm");
if (nnmpattr != null)
{
loc.NumberOfNoPenaltyMutation = int.Parse(nnmpattr);
}
} while (source.ReadToNextSibling("location"));
}
} while (source.ReadToNextSibling("query"));
}
return result;
}
示例13: getFunctionDocAndExample
protected string getFunctionDocAndExample(XmlReader reader)
{
//assumes doc is before example. Otherwise, could miss an example.
string strRes = "";
bool bFound = reader.ReadToDescendant("doc");
if (bFound) strRes += (unencodeXml(reader.ReadString()));
bFound = reader.ReadToNextSibling("example");
if (bFound) strRes += ("\r\n\r\nExample:\r\n" + unencodeXml(reader.ReadString()));
reader.Close();
return strRes;
}
示例14: FromXml
public override bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Item")
{
return false;
}
reader.ReadStartElement();
if (reader.Name == "Order" || reader.ReadToNextSibling("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Type" || reader.ReadToNextSibling("Type"))
{
Type = reader.ReadElementContentAsInt();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
{
Text = reader.ReadElementContentAsString();
}
if (reader.Name == "Data" || reader.ReadToNextSibling("Data"))
{
Data = reader.ReadElementContentAsString();
}
if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
{
Memo = reader.ReadElementContentAsString();
}
reader.ReadEndElement();
return true;
}
示例15: LoadPlugin
/// <summary>
/// Parses an XML plugin, calling the corresponding method in
/// IPluginVisitor for each XML tag it encounters.
/// </summary>
/// <param name="reader">The XmlReader to read the plugin XML from.</param>
/// <param name="visitor">The IPluginVisitor to call for each XML tag.</param>
public static void LoadPlugin(XmlReader reader, IPluginVisitor visitor)
{
if (!reader.ReadToNextSibling("plugin"))
throw new ArgumentException("The XML file is missing a <plugin> tag.");
var baseSize = 0;
if (reader.MoveToAttribute("baseSize"))
baseSize = ParseInt(reader.Value);
if (!visitor.EnterPlugin(baseSize)) return;
ReadElements(reader, true, visitor);
visitor.LeavePlugin();
}