本文整理汇总了C#中XmlReader.ReadElementString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementString方法的具体用法?C# XmlReader.ReadElementString怎么用?C# XmlReader.ReadElementString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
var empty = reader.IsEmptyElement;
reader.ReadStartElement();
if (!empty)
{
while (reader.MoveToContent() == XmlNodeType.Element)
{
if (reader.Name == @"ProductName" && !reader.IsEmptyElement)
{
ProductName = reader.ReadElementString();
}
else if (reader.Name == @"GlyphColor" && !reader.IsEmptyElement)
{
GlyphColor = ParseColor(reader.ReadElementString());
}
else
{
// consume the bad element and skip to next sibling or the parent end element tag
reader.ReadOuterXml();
}
}
reader.MoveToContent();
reader.ReadEndElement();
}
}
示例2: TwoWayRequest
// TwoWayRequest: Accept two integer values, return their sum
public byte[] TwoWayRequest(WsWsaHeader header, XmlReader reader)
{
try
{
// Find beginning of request
reader.ReadStartElement("TwoWayRequest", SimpleServiceNamespaceUri);
// Find the values to be added
int X = Convert.ToInt32(reader.ReadElementString("X", SimpleServiceNamespaceUri));
int Y = Convert.ToInt32(reader.ReadElementString("Y", SimpleServiceNamespaceUri));
Log.Comment("");
Log.Comment("X = " + X.ToString() + " Y = " + Y.ToString());
Log.Comment(X.ToString() + " + " + Y.ToString() + " = " + ((int)(X + Y)).ToString());
Log.Comment("");
// Return the response
return TwoWayResponse(header, X + Y);
}
catch (Exception e)
{
// Something went wrong
throw new WsFaultException(header, WsFaultType.XmlException, e.ToString());
}
}
示例3: ReadXml
public void ReadXml(XmlReader r)
{
r.Read(); // move past container
r.ReadStartElement("dictionary");
while (r.NodeType != XmlNodeType.EndElement) {
r.ReadStartElement("item", NS);
string key = r.ReadElementString("key", NS);
string value = r.ReadElementString("value", NS);
r.ReadEndElement();
r.MoveToContent();
dictionary.Add(key, value);
}
}
示例4:
void IXmlSerializable.ReadXml(XmlReader r)
{
r.MoveToContent();
r.ReadStartElement("Employee");
r.ReadStartElement("Name");
FirstName = r.ReadElementString("First", ns);
LastName = r.ReadElementString("Last", ns);
r.ReadEndElement();
r.MoveToContent();
ID = Int32.Parse(r.ReadElementString("ID", ns));
r.ReadEndElement();
}
示例5: while
void IXmlSerializable.ReadXml(XmlReader reader)
{
reader.Read();
reader.ReadStartElement("dictionary");
while (reader.NodeType != XmlNodeType.EndElement)
{
reader.ReadStartElement("item");
string key = reader.ReadElementString("key");
string value = reader.ReadElementString("value");
reader.ReadEndElement();
reader.MoveToContent();
dictionary.Add(key, value);
}
reader.ReadEndElement();
}
示例6: ReadElement
private void ReadElement(XmlReader reader, Bag parent) {
var name = XmlConvert.DecodeName(reader.LocalName);
var type = reader["type"];
// is it a value node ? i.e. type=""
if (type != null) {
if (type == "Array") {
// go to first item
parent.SetMember(name, ReadArray(reader));
reader.Read();
}
else {
var typeCode = (TypeCode)Enum.Parse(typeof(TypeCode), type);
var value = SConvert.XmlDecode(typeCode, reader.ReadElementString());
parent.SetMember(name, value);
}
}
else {
var grappe = new Bag();
reader.Read();
parent.SetMember(name, grappe);
while (reader.MoveToContent() == XmlNodeType.Element) {
ReadElement(reader, grappe);
}
reader.Read();
}
}
示例7: AddString
void AddString(XmlReader reader, Hashtable strings)
{
string key = reader.Name;
if (strings.ContainsKey(key))
throw new InvalidDataException("Already contains key (" + key + ")");
reader.Read();
while (reader.IsStartElement())
{
string name = reader.Name;
string value = reader.ReadElementString();
if (string.IsNullOrEmpty(value))
continue;
if (name == culture.Name)
strings.Add(key, value);
if (name == "default" && culture.Equals(CultureInfo.InvariantCulture))
strings.Add(key, value);
}
reader.ReadEndElement();
}
示例8: TryParse
/// <summary>Reads the Elo from an xml writer.</summary>
/// <remarks>
/// Uses the string parse function of Elo.
/// </remarks>
/// <param name="reader">An xml reader.</param>
void IXmlSerializable.ReadXml(XmlReader reader)
{
var s = reader.ReadElementString();
BotInfo info;
TryParse(s, out info);
m_Name = info.m_Name;
m_Version = info.m_Version;
m_Inactive = info.m_Inactive;
}
示例9: readBuilding
private void readBuilding(XmlReader inReader)
{
Building building = new Building();
while (inReader.Read())
{
if (inReader.NodeType == XmlNodeType.Element)
{
switch (inReader.Name.ToLower())
{
case "name":
building.Name = inReader.ReadElementString();
break;
case "identifier":
building.Identifier = inReader.ReadElementString();
break;
case "type":
switch (inReader.ReadElementString().ToLower())
{
case "pollutionreducer":
building.Type = BuildingTypes.PollutionReducer;
break;
case "powerplant":
building.Type = BuildingTypes.Powerplant;
break;
case "house":
building.Type = BuildingTypes.House;
break;
case "storage":
building.Type = BuildingTypes.Storage;
break;
}
break;
case "properties":
readProperties(inReader.ReadSubtree(), building.Values);
break;
case "active":
readActive(inReader.ReadSubtree(), building.Values);
break;
case "passive":
readPassive(inReader.ReadSubtree(), building.Values);
break;
case "construct":
readConstruct(inReader.ReadSubtree(), building.Values);
break;
case "upgrades":
readUpgrades(inReader.ReadSubtree(), building);
break;
}
}
}
if (building.isValid()) Buildings.Add(building);
}
示例10: Person
internal Person(XmlReader rdr)
{
rdr.ReadStartElement("person");
this.Id = int.Parse(rdr.ReadElementString("id"));
this.FirstName = rdr.ReadElementString("first_name");
this.LastName = rdr.ReadElementString("last_name");
//Skipping Image Fields
rdr.ReadToFollowing("title");
this.Title = rdr.ReadElementString("title");
this.Company = rdr.ReadElementString("company");
int companyId;
if (int.TryParse(rdr.ReadElementString("company_id"), out companyId))
this.CompanyId = companyId;
this.Tags = Tag.BuildList(rdr);
this.Locations = Location.BuildList(rdr);
this.MegaComments = MegaComment.BuildList(rdr);
this.Notes = rdr.ReadElementString("notes");
this.CreatedAt = rdr.ReadElementString("created_at").FromBatchBookFormat();
this.UpdatedAt = rdr.ReadElementString("updated_at").FromBatchBookFormat();
rdr.ReadEndElement();
}
示例11: OneWay
public byte[] OneWay(WsWsaHeader header, XmlReader reader)
{
try
{
// Find beginning of request
reader.ReadStartElement("OneWay", SimpleServiceNamespaceUri);
// Find the integer value
int number = Convert.ToInt32(reader.ReadElementString("Param", SimpleServiceNamespaceUri));
Log.Comment("");
Log.Comment("Integer = " + number.ToString());
Log.Comment("");
return new byte[0]; // Empty response
}
catch (Exception e)
{
// Something went wrong
throw new WsFaultException(header, WsFaultType.XmlException, e.ToString());
}
}
示例12: ParsePage
private Page ParsePage(XmlReader PageElement)
{
Page page = new Page();
int GotCount = 0;
while (PageElement.Read())
{
switch (PageElement.Name)
{
case "title":
page.Title = PageElement.ReadElementString();
GotCount++;
break;
case "redirect":
page.RedirectTo = PageElement.GetAttribute("title");
GotCount++;
break;
case "text":
page.Text = PageElement.ReadElementString();
GotCount++;
break;
}
if (GotCount == 3) break;
}
return page;
}
示例13: ReadMethodName
private static String ReadMethodName(XmlReader reader)
{
RecursiveTypeSerializer.CheckTag(reader, XmlRpcSpec.METHOD_NAME_TAG);
return reader.ReadElementString();
}
示例14: ImportWebPart
public virtual WebPart ImportWebPart(XmlReader reader, out string errorMessage)
{
WebPart part2;
this.Personalization.EnsureEnabled(true);
if (reader == null)
{
throw new ArgumentNullException("reader");
}
bool flag = false;
if (this.UsePermitOnly)
{
this.MinimalPermissionSet.PermitOnly();
flag = true;
}
string str = string.Empty;
try
{
try
{
Type type;
IDictionary personalizablePropertyEntries;
reader.MoveToContent();
reader.ReadStartElement("webParts");
ImportSkipTo(reader, "webPart");
string attribute = reader.GetAttribute("xmlns");
if (string.IsNullOrEmpty(attribute))
{
errorMessage = System.Web.SR.GetString("WebPart_ImportErrorNoVersion");
return null;
}
if (!string.Equals(attribute, "http://schemas.microsoft.com/WebPart/v3", StringComparison.OrdinalIgnoreCase))
{
errorMessage = System.Web.SR.GetString("WebPart_ImportErrorInvalidVersion");
return null;
}
ImportReadTo(reader, "metaData");
reader.ReadStartElement("metaData");
string str3 = null;
string path = null;
ImportSkipTo(reader, "type");
str3 = reader.GetAttribute("name");
path = reader.GetAttribute("src");
ImportSkipTo(reader, "importErrorMessage");
str = reader.ReadElementString();
WebPart part = null;
Control control = null;
try
{
bool isShared = this.Personalization.Scope == PersonalizationScope.Shared;
if (!string.IsNullOrEmpty(str3))
{
if (this.UsePermitOnly)
{
CodeAccessPermission.RevertPermitOnly();
flag = false;
this.MediumPermissionSet.PermitOnly();
flag = true;
}
type = WebPartUtil.DeserializeType(str3, true);
if (this.UsePermitOnly)
{
CodeAccessPermission.RevertPermitOnly();
flag = false;
this.MinimalPermissionSet.PermitOnly();
flag = true;
}
if (!this.IsAuthorized(type, null, null, isShared))
{
errorMessage = System.Web.SR.GetString("WebPartManager_ForbiddenType");
return null;
}
if (!type.IsSubclassOf(typeof(WebPart)))
{
if (!type.IsSubclassOf(typeof(Control)))
{
errorMessage = System.Web.SR.GetString("WebPartManager_TypeMustDeriveFromControl");
return null;
}
control = (Control) this.Internals.CreateObjectFromType(type);
control.ID = this.CreateDynamicWebPartID(type);
part = this.CreateWebPart(control);
}
else
{
part = (WebPart) this.Internals.CreateObjectFromType(type);
}
}
else
{
if (!this.IsAuthorized(typeof(UserControl), path, null, isShared))
{
errorMessage = System.Web.SR.GetString("WebPartManager_ForbiddenType");
return null;
}
if (this.UsePermitOnly)
{
CodeAccessPermission.RevertPermitOnly();
flag = false;
}
control = this.Page.LoadControl(path);
//.........这里部分代码省略.........
示例15: ReadXml
public void ReadXml (XmlReader reader)
{
// Read the element enclosing the object
reader.ReadStartElement();
reader.MoveToContent ();
// Reads the "data" element
reader.ReadStartElement();
reader.MoveToContent ();
while (reader.NodeType != XmlNodeType.EndElement)
{
if (reader.NodeType == XmlNodeType.Element)
{
string key = reader.LocalName;
data [key] = reader.ReadElementString ();
}
else
reader.Skip ();
reader.MoveToContent ();
}
reader.ReadEndElement ();
}