本文整理汇总了C#中System.Xml.XmlReader.ReadToDescendant方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadToDescendant方法的具体用法?C# XmlReader.ReadToDescendant怎么用?C# XmlReader.ReadToDescendant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadToDescendant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
}
示例2: 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 = "";
}
}
示例3: CreateResponseException
public static Exception CreateResponseException(XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException("reader");
reader.MoveToElement();
if (!reader.ReadToDescendant("err"))
throw new XmlException("No error element found in XML");
int code = 0;
string message = (string) null;
while (reader.MoveToNextAttribute())
{
if (reader.LocalName == "code")
{
try
{
code = int.Parse(reader.Value, NumberStyles.Any, (IFormatProvider) NumberFormatInfo.InvariantInfo);
}
catch (FormatException ex)
{
throw new FlickrException("Invalid value found in code attribute. Value '" + (object) code + "' is not an integer");
}
}
else if (reader.LocalName == "msg")
message = reader.Value;
}
return (Exception) ExceptionHandler.CreateException(code, message);
}
示例4: 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"));
}
}
}
示例5: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Lib")
{
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 == "Text" || reader.ReadToNextSibling("Text"))
{
Text = reader.ReadElementContentAsString();
}
if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
{
Memo = reader.ReadElementContentAsString();
}
return true;
}
示例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: ReadXml
public override void ReadXml(XmlReader reader)
{
reader.MoveToContent();
if (reader.AttributeCount == 0)
throw new MissingXmlAttributeException(@"Missing XML attribute ""value"".");
Name = reader["name"];
if (reader.IsEmptyElement)
{
reader.ReadEndElement();
return;
}
if (reader.ReadToDescendant(ChildXmlTag))
{
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == ChildXmlTag)
{
reader.ReadStartElement();
reader.MoveToContent();
IilParameter p = IilParameter.fromString(reader.LocalName);
p.ReadXml(reader);
Parameters.Add(p);
reader.ReadEndElement();
}
}
reader.ReadEndElement();
//reader.Read();
}
示例8: 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;
}
示例9: expandNamespace_function
private void expandNamespace_function(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader)
{
bool bContinue = reader.ReadToDescendant("function");
while (bContinue)
{
// if (reader.GetAttribute("args") != null) MessageBox.Show("instance?");
NodeDocLnzFunction node = new NodeDocLnzFunction(strSection, strNamespace, reader.GetAttribute("name"));
bool bInstance = reader.GetAttribute("instance") == "true";
node.bIsInstanceMethod = bInstance;
string strArgs = reader.GetAttribute("args"); if (strArgs != null && strArgs != "") node.strArguments = strArgs;
string strReturns = reader.GetAttribute("returns"); if (strReturns != null && strReturns != "") node.strReturns = strReturns;
node.strDocumentationAndExample = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example
if (bInstance)
{
//MessageBox.Show("instance found");
outInstanceMethods.Nodes.Add(node);
}
else
outNodes.Add(node);
bContinue = ReadToNextSibling(reader, "function");
}
reader.Close();
}
示例10: expandNamespace_function
private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader)
{
bool bContinue = reader.ReadToDescendant("function");
while (bContinue)
{
NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name"));
outNodes.Add(node);
bool bInstance = reader.GetAttribute("instance") == "true";
node.bIsInstanceMethod = bInstance;
string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax;
node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example
if (this.emphasizeStaticness())
{
if (!bInstance)
{
//change visible node text to emphasize static-ness
node.Text = node.strNamespacename + "." + node.strFunctionname;
}
}
bContinue = ReadToNextSibling(reader, "function");
}
reader.Close();
}
示例11: LoadFromXml
public void LoadFromXml (XmlReader reader)
{
reader.ReadToDescendant ("plist");
while (reader.Read () && reader.NodeType != XmlNodeType.Element);
if (!reader.EOF)
root = LoadFromNode (reader);
}
示例12:
void IFlickrParsable.Load(XmlReader reader)
{
if (reader.LocalName != "auth")
return;
reader.ReadToDescendant("access_token");
this.Token = reader.GetAttribute("oauth_token");
this.TokenSecret = reader.GetAttribute("oauth_token_secret");
}
示例13: GetCreated
// Gets the creation date of the Project Gutenberg catalog. This method should be called
// before parsing the books and volumes because the creation date is at the beginning;
// calling it later would not find the XML element with the date any more and would
// continue reading the content to the end, skipping all content. This method expects a
// reader returned by the method Open.
public Date GetCreated(XmlReader reader)
{
Log.Verbose("Getting creation date...");
if (!reader.ReadToFollowing("Description", RDF))
throw new ApplicationException("Missing creation time.");
if (!reader.ReadToDescendant("value", RDF))
throw new ApplicationException("Missing creation date value.");
return reader.ReadElementContentAsDate();
}
示例14: FromXmlReader
public string FromXmlReader (XmlReader reader)
{
if (!reader.ReadToDescendant ("head"))
return null;
if (!reader.ReadToNextSibling ("body"))
return null;
return reader.ReadInnerXml ();
}
示例15: ReadXml
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
reader.ReadToDescendant("Value1");
Value1 = reader.ReadString();
reader.ReadEndElement();
reader.ReadStartElement("Value2");
Value2 = int.Parse(reader.ReadString());
ReadXmlCalled = true;
}