本文整理汇总了C#中System.Xml.XmlReader.ReadElementContentAsString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementContentAsString方法的具体用法?C# XmlReader.ReadElementContentAsString怎么用?C# XmlReader.ReadElementContentAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementContentAsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
public void ReadXml(XmlReader reader)
{
while (!reader.EOF)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case ModeElementName:
TranslitModeEnum mode;
string elementContent = reader.ReadElementContentAsString();
if (!Enum.TryParse(elementContent, true, out mode))
{
throw new InvalidDataException(string.Format("Invalit ignore Title value read: {0}",elementContent));
}
Mode = mode;
continue;
case FileNameElementName:
FileName = reader.ReadElementContentAsString();
continue;
}
}
reader.Read();
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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");
}
}
示例5: while
void IFlickrParsable.Load(XmlReader reader)
{
reader.Read();
while (reader.LocalName != "photos")
{
switch (reader.LocalName)
{
case "firstdatetaken":
this.FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
continue;
case "firstdate":
this.FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
continue;
case "count":
this.PhotoCount = reader.ReadElementContentAsInt();
continue;
case "views":
this.Views = reader.ReadElementContentAsInt();
continue;
default:
reader.Skip();
continue;
}
}
reader.Read();
}
示例6: ReadXml
public override void ReadXml(XmlReader reader)
{
if (CheckEmptyNode(reader, "ContactPersonPrimary", Namespace))
return;
while (!reader.EOF)
{
if (reader.IsStartElement())
{
var isEmpty = reader.IsEmptyElement;
switch (reader.LocalName)
{
case "ContactPerson":
ContactPerson = isEmpty ? string.Empty : reader.ReadElementContentAsString();
break;
case "ContactOrganization":
ContactOrganization = isEmpty ? string.Empty : reader.ReadElementContentAsString();
break;
default:
reader.Skip();
break;
}
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
reader.ReadEndElement();
return;
}
else
{
reader.Read();
}
}
}
示例7: _getHeadersFromEntry
private static string _getHeadersFromEntry(XmlReader oEntry)
{
StringBuilder builder = new StringBuilder();
while (oEntry.Read())
{
string str;
if ((oEntry.NodeType == XmlNodeType.Element) && ((str = oEntry.Name) != null))
{
if (!(str == "name"))
{
if (str == "value")
{
goto Label_0052;
}
}
else
{
builder.Append(oEntry.ReadElementContentAsString());
builder.Append(": ");
}
}
continue;
Label_0052:
builder.Append(oEntry.ReadElementContentAsString());
builder.Append("\r\n");
}
return builder.ToString();
}
示例8: ParseXml
internal static MarketplaceAppCapabilityNode ParseXml(XmlReader reader)
{
var node = new MarketplaceAppCapabilityNode();
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.Name)
{
case "id":
node.Id = reader.ReadElementContentAsString();
break;
case "string":
node.Title = reader.ReadElementContentAsString();
break;
case "disclosure":
node.Disclosure = reader.ReadElementContentAsString();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
return node;
}
示例9: CreateBeatFromXmlSubtree
/// <summary>
/// Reads an Xml Subtree and looks for a Node with the name "Location" and "Mood"
/// If both nodes are found then a Beat object is created and added to the m_BeatsList
/// </summary>
/// <param name="Subtree">The XML subtree to Read</param>
private void CreateBeatFromXmlSubtree(XmlReader Subtree)
{
string Location = "";
string MoodString = "";
while (Subtree.Read())
{
if (Subtree.NodeType == XmlNodeType.Element)
{
switch(Subtree.Name)
{
case "Location":
Location = Subtree.ReadElementContentAsString();
break;
case "Mood":
MoodString = Subtree.ReadElementContentAsString();
break;
}
}
}
//Ensure both values have been set
if (Location != "" && MoodString != "")
{
m_BeatsList.Add(new Beat(Location, ParseMood(MoodString)));
}
}
示例10: ParseXml
internal static WindowsStoreServiceAppScreenshotNode ParseXml(XmlReader reader)
{
var node = new WindowsStoreServiceAppScreenshotNode();
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.Name)
{
case "U":
node.Url = reader.ReadElementContentAsString();
break;
case "Cap":
node.Caption = reader.ReadElementContentAsString();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
return node;
}
示例11: Searchers
public Searchers(XmlReader reader)
{
this.Choices = new List<Choice>();
this.CurrentSearch = "";
reader.Read();
if (reader.Name != "TheSearchers")
return; // bail out
reader.Read();
while (!reader.EOF)
{
if ((reader.Name == "TheSearchers") && !reader.IsStartElement())
break; // all done
if (reader.Name == "Current")
this.CurrentSearch = reader.ReadElementContentAsString();
else if (reader.Name == "Choice")
{
string url = reader.GetAttribute("URL");
if (url == null)
url = reader.GetAttribute("URL2");
else
{
// old-style URL, replace "!" with "{ShowName}+{Season}+{Episode}"
url = url.Replace("!", "{ShowName}+{Season}+{Episode}");
}
this.Add(reader.GetAttribute("Name"), url);
reader.ReadElementContentAsString();
}
else
reader.ReadOuterXml();
}
}
示例12: 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;
}
示例13: ExamQuestion
public ExamQuestion(XmlReader reader)
: this()
{
QuestionIdentifier = reader.GetAttribute("identifier");
Question = reader.GetAttribute("question");
Image = reader.GetAttribute("image");
while (!reader.EOF)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == "Answer")
Answer = reader.ReadElementContentAsString();
else if (reader.Name == "Distractor")
Distractors.Add(reader.ReadElementContentAsString());
else
reader.Read();
break;
case XmlNodeType.EndElement:
return;
default:
reader.Read();
break;
}
}
}
示例14: ReadXml
protected virtual void ReadXml(XmlReader reader, SyndicationFeed result)
{
if (result == null)
throw new ArgumentNullException("result");
if (reader == null)
throw new ArgumentNullException("reader");
reader.ReadStartElement(); // Read in <RDF>
reader.ReadStartElement("channel"); // Read in <channel>
while (reader.IsStartElement()) // Process <channel> children
{
if (reader.IsStartElement("title"))
result.Title = new TextSyndicationContent(reader.ReadElementContentAsString());
else if (reader.IsStartElement("link"))
result.Links.Add(new SyndicationLink(new Uri(reader.ReadElementContentAsString())));
else if (reader.IsStartElement("description"))
result.Description = new TextSyndicationContent(reader.ReadElementContentAsString());
else
reader.Skip();
}
reader.ReadEndElement(); // Read in </channel>
while (reader.IsStartElement())
{
if (reader.IsStartElement("item"))
{
result.Items = ReadItems(reader, result);
break;
}
reader.Skip();
}
}
示例15: Read
internal static void Read(XmlReader reader, Item item)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (item == null)
throw new ArgumentNullException("item");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
reader.ReadStartElement(ItemSerializer.Item);
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, ItemSerializer.Item))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case ItemSerializer.Id:
item.Id = reader.ReadElementContentAsString();
break;
case ItemSerializer.Description:
item.Description = reader.ReadElementContentAsString();
break;
case ItemSerializer.Quantity:
item.Quantity = reader.ReadElementContentAsInt();
break;
case ItemSerializer.Amount:
item.Amount = reader.ReadElementContentAsDecimal();
break;
case ItemSerializer.Weight:
item.Weight = reader.ReadElementContentAsLong();
break;
case ItemSerializer.ShippingCost:
item.ShippingCost = reader.ReadElementContentAsDecimal();
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}