本文整理汇总了C#中System.Xml.XmlReader.ReadToFollowing方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadToFollowing方法的具体用法?C# XmlReader.ReadToFollowing怎么用?C# XmlReader.ReadToFollowing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadToFollowing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseItems
/// <summary>
/// Parse the results of the Bing search
/// </summary>
/// <param name="reader">The xml reader containing the search results</param>
public Collection<Article> ParseItems(XmlReader reader, Feed ownerFeed)
{
Collection<Article> results = new Collection<Article>();
reader.ReadToFollowing("item");
do
{
if (reader.ReadToFollowing("title"))
{
string name = reader.ReadElementContentAsString();
if (reader.ReadToFollowing("link"))
{
string uri = reader.ReadElementContentAsString();
// Assign feed information to Article object.
Article newResult = new Article
{
ArticleTitle = name,
ArticleBaseURI = uri
};
// Safely add the search result to the collection.
lock (_lockObject)
{
results.Add(newResult);
}
}
}
} while (reader.ReadToFollowing("item"));
return results;
}
示例2: 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"));
}
}
}
示例3: ProcessItem
private void ProcessItem(XmlReader reader)
{
reader.MoveToContent();
Material tmpMaterial = new Material();
tmpMaterial.name = reader.GetAttribute("displayname");
tmpMaterial.type = reader.GetAttribute("type");
if (reader.ReadToFollowing("ambient"))
{
reader.MoveToContent();
tmpMaterial.ambient.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.ambient.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.ambient.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.ambient.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("specular"))
{
reader.MoveToContent();
tmpMaterial.specular.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.specular.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.specular.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.specular.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("diffuse"))
{
reader.MoveToContent();
tmpMaterial.diffuse.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.diffuse.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.diffuse.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.diffuse.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("emissive"))
{
reader.MoveToContent();
tmpMaterial.emission.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.emission.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.emission.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.emission.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("shininess"))
{
reader.MoveToContent();
tmpMaterial.shininess = (float)Convert.ToDouble(reader.GetAttribute("value").Replace(".", ","));
}
if (reader.ReadToFollowing("texture"))
{
reader.MoveToContent();
tmpMaterial.LoadTexture(reader.GetAttribute("file"));
}
this.lstMaterial.Add(tmpMaterial);
}
示例4: FromOriginalXmlFormat
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="xmlData"></param>
/// <returns>The scene object deserialized. Null on failure.</returns>
public static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
SceneObjectGroup sceneObject = null;
try
{
int linkNum;
reader.ReadToFollowing("RootPart");
reader.ReadToFollowing("SceneObjectPart");
sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
reader.ReadToFollowing("OtherParts");
if(reader.IsEmptyElement)
{
/* do not try to read parts on empty elements */
}
else if (reader.ReadToDescendant("Part"))
{
do
{
if (reader.ReadToDescendant("SceneObjectPart"))
{
SceneObjectPart part = SceneObjectPart.FromXml(reader);
linkNum = part.LinkNum;
sceneObject.AddPart(part);
part.LinkNum = linkNum;
part.TrimPermissions();
}
}
while (reader.ReadToNextSibling("Part"));
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject.LoadScriptState(reader);
}
catch (Exception e)
{
m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed. Exception {0}", e);
return null;
}
return sceneObject;
}
示例5: 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");
}
}
示例6: Load
public static IList<FileDto> Load(XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (!reader.ReadToFollowing("Translations", Ns))
return null;
var files = new List<FileDto>();
while (true)
{
if (!reader.Read())
return null;
if (reader.NodeType == XmlNodeType.Whitespace)
continue;
if (reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element)
return null;
var file = ReadFile(reader);
if (file == null)
return null;
files.Add(file);
}
return files;
}
示例7: GetValue
public string GetValue(string key)
{
_reader = XmlReader.Create(_configFile);
_reader.ReadToFollowing(key);
_reader.MoveToFirstAttribute();
return _reader.Value;
}
示例8: ReadXml
public void ReadXml(XmlReader xmlReader)
{
while (xmlReader.ReadToFollowing("assembly"))
{
Name = xmlReader.GetAttribute("name");
Version = xmlReader.GetAttribute("version");
if (!xmlReader.IsEmptyElement)
{
var childReader = xmlReader.ReadSubtree();
while (childReader.Read())
{
if (childReader.NodeType == XmlNodeType.Element)
{
if (childReader.Name == "type")
{
var type = new TypeInfo();
type.ReadXml(xmlReader);
Types.Add(type);
}
}
}
}
}
}
示例9: ReadMedia
private static IEnumerable<string> ReadMedia(XmlReader media)
{
while (media.ReadToFollowing("local"))
{
media.MoveToFirstAttribute();
yield return media.ReadContentAsString();
}
}
示例10: DeserializeSpecVersion
//public static string HostAddress
//{
// get
// {
// foreach (IPAddress address in Dns.GetHostAddresses (Dns.GetHostName ())) {
// if (address.AddressFamily == AddressFamily.InterNetwork) {
// return address;
// }
// }
// }
//}
public static Version DeserializeSpecVersion(XmlReader reader)
{
try {
// We assume the elements appear in this order
reader.ReadToFollowing ("major");
reader.Read ();
var major = reader.ReadContentAsInt ();
reader.ReadToFollowing ("minor");
reader.Read ();
var minor = reader.ReadContentAsInt ();
return new Version (major, minor);
} catch (Exception e) {
throw new UpnpDeserializationException ("There was a problem deserializing a spec version.", e);
} finally {
reader.Close ();
}
}
示例11: 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();
}
示例12: ResponseXmlException
void IFlickrParsable.Load(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException("reader");
if (!reader.ReadToFollowing("photos"))
throw new ResponseXmlException("Unable to find \"photos\" element in response.");
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxdisplaypx":
MaximumDisplayPixels = reader.ReadContentAsInt();
break;
case "maxupload":
MaximumPhotoUpload = reader.ReadContentAsLong();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
if (!reader.ReadToFollowing("videos"))
throw new ResponseXmlException("Unable to find \"videos\" element in response.");
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxduration":
MaximumVideoDuration = reader.ReadContentAsInt();
break;
case "maxupload":
MaximumVideoUpload = reader.ReadContentAsLong();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Skip();
}
示例13: 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 = "";
}
}
示例14: Load
internal virtual void Load (XmlReader reader)
{
reader.ReadToFollowing (XmlName);
FillLocation (reader);
while (reader.MoveToNextAttribute ()) {
LoadAttribute (reader.Name, reader.Value);
}
reader.MoveToElement ();
LoadValue (reader);
}
示例15: ReadDeficiencies
public static List<Deficiency> ReadDeficiencies(XmlReader deficienciesReader)
{
List<Deficiency> deficiencyList = new List<Deficiency>();
while (deficienciesReader.ReadToFollowing("Deficiency"))
{
deficiencyList.Add( ReadDeficiency(deficienciesReader.ReadSubtree()) );
}
return deficiencyList;
}