本文整理汇总了C#中System.Xml.XmlReader.ReadOuterXml方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadOuterXml方法的具体用法?C# XmlReader.ReadOuterXml怎么用?C# XmlReader.ReadOuterXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadOuterXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeSection
/// <summary>
/// Reads XML from the configuration file.
/// </summary>
/// <param name="xmlReader">The XmlReader object, which reads from the configuration file.</param>
protected internal override void DeserializeSection(XmlReader xmlReader)
{
if (RawXml == null)
RawXml = xmlReader.ReadOuterXml();
else
xmlReader.Skip();
}
示例2: Deserialize
public static object Deserialize(Type type, XmlReader reader, bool readInnerXml)
{
if (null == type) throw new ArgumentNullException("type");
if (null == reader) throw new ArgumentNullException("reader");
if (reader.NodeType != XmlNodeType.Element) throw new ArgumentException("reader is not positioned on an element");
object value = null;
StringBuilder serializationBuilder = new StringBuilder();
serializationBuilder.Append("<?xml version=\"1.0\"?>");
if (readInnerXml)
{
serializationBuilder.AppendLine(reader.ReadInnerXml());
}
else
{
serializationBuilder.AppendLine(reader.ReadOuterXml());
}
string serialization = serializationBuilder.ToString();
using (StringReader stringReader = new StringReader(serialization))
{
XmlSerializer serializer = new XmlSerializer(type);
value = serializer.Deserialize(stringReader);
}
return value;
}
示例3: 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();
}
}
示例4: DeserializeSection
protected internal override void DeserializeSection(XmlReader xmlReader) {
if (!xmlReader.Read() || xmlReader.NodeType != XmlNodeType.Element) {
throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_expected_to_find_element), xmlReader);
}
_rawXml = xmlReader.ReadOuterXml();
_isModified = true;
}
示例5: ReadXml
public void ReadXml(XmlReader reader)
{
int sequenceCount = 0;
bool isEmpty = reader.IsEmptyElement;
reader.ReadStartElement();
if (isEmpty)
return;
while (reader.NodeType == XmlNodeType.Element)
{
if (sequenceCount == 0 || reader.IsStartElement("title"))
{
PitchSequences.Add(new PitchSequence());
sequenceCount++;
}
if (reader.IsStartElement("title"))
PitchSequences[sequenceCount - 1].Title = reader.ReadElementString();
else if (reader.IsStartElement("pitch"))
{
var pitch = new Pitch();
pitch.ReadXml(reader);
PitchSequences[sequenceCount - 1].Pitches.Add(pitch);
}
else
reader.ReadOuterXml();
}
reader.ReadEndElement();
}
示例6: 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();
}
}
示例7: ReadXml
public void ReadXml(XmlReader reader)
{
var s = reader.ReadOuterXml();
var x = XDocument.Parse(s);
if (x.Root == null) return;
foreach (var e in x.Root.Elements())
{
var name = e.Name.ToString();
switch (name)
{
case "List":
foreach (var ee in e.Elements())
_list.Add(Util.DeSerialize<OnlineRegPersonModel>(ee.ToString()));
break;
case "History":
foreach (var ee in e.Elements())
_history.Add(ee.Value);
break;
default:
Util.SetPropertyFromText(this, name, e.Value);
break;
}
}
}
示例8: ReadXml
/// <summary>
/// convert the xml representation of this class into the document and metadata properties
/// </summary>
/// <param name="reader"></param>
public void ReadXml(XmlReader reader)
{
// good place for debug logging
try
{
// take the reader, turn into an XmlDocument, then parse out the metadata and documents
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(reader.ReadOuterXml());
submissionMetadata = xmldoc.SelectSingleNode(@".//*[local-name()='SubmitObjectsRequest']"); // cheating and ignoring namespaces
if (submissionMetadata == null)
{
// good place for debug logging
throw new Exception("P&RRequestXDSB Reader cannot find SubmitObjectsRequest");
}
XmlNodeList theDocs = xmldoc.SelectNodes(@".//*[local-name()='Document']");
if (theDocs == null)
{
// good place for debug logging
throw new Exception("P&RRequestXDSB Reader cannot find Document");
}
foreach (XmlNode aDoc in theDocs)
{
SubmissionDocument theDoc = new SubmissionDocument();
theDoc.documentID = aDoc.Attributes["id"].Value.ToString();
theDoc.documentText = Convert.FromBase64String(aDoc.InnerText);
submissionDocuments.Add(theDoc);
}
}
catch (Exception ex)
{
// good place for debug logging
throw ex;
}
// good place for debug logging
}
示例9: CreateVehicleInfoChildElement
private XElement CreateVehicleInfoChildElement(XmlReader reader)
{
XElement vehInfoElement = new XElement(DataLoadConstants.ELEMENT_VEHILCEINFO);
XElement regIDElement = new XElement(XDocument.Parse(reader.ReadOuterXml()).Root);
vehInfoElement.Add(regIDElement);
return vehInfoElement;
}
示例10: ReadFrom
private static EndpointAddress ReadFrom (System.ServiceModel.Channels.AddressingVersion addressingVersion, XmlReader xreader)
{
string xml = xreader.ReadOuterXml ();
StringReader sreader = new StringReader (xml);
XmlReader reader = XmlReader.Create (sreader);
Uri uri = null;
EndpointIdentity identity = null;
reader.MoveToContent ();
List<AddressHeader> header = new List<AddressHeader> ();
while (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) {
if (reader.LocalName == "EndpointReference") {
reader.Read ();
} else if (reader.LocalName == "Address" &&
reader.NodeType == XmlNodeType.Element &&
!reader.IsEmptyElement)
uri = new Uri (reader.ReadElementContentAsString ());
else if (reader.LocalName == "Identity" &&
reader.NodeType == XmlNodeType.Element &&
!reader.IsEmptyElement) {
//How can key re-empact Identity
identity = new X509CertificateEndpointIdentity (new System.Security.Cryptography.X509Certificates.X509Certificate2 ("powershell.pfx", "mono"));
break;
} else {
var headerName = reader.LocalName;
var headerNamespace = reader.NamespaceURI;
reader.MoveToContent ();
reader.ReadStartElement ();
var obj = reader.ReadElementContentAs (GetTypeFromLocalName (reader.LocalName), new XmlNamespaceManager (reader.NameTable));
header.Add (AddressHeader.CreateAddressHeader (headerName, headerNamespace, obj));
reader.MoveToContent ();
reader.ReadEndElement ();
}
}
return identity == null ? new EndpointAddress(uri, header.ToArray ()) : new EndpointAddress(uri, identity, header.ToArray ());
}
示例11: ReadOuterXml
private string ReadOuterXml(XmlReader forReader) {
try {
forReader.MoveToContent();
return forReader.ReadOuterXml();
} finally {
forReader.Close();
}
}
示例12: ReadXml
public void ReadXml(XmlReader reader)
{
var s = reader.ReadOuterXml();
var x = XDocument.Parse(s);
if (x.Root == null) return;
eqset = 0;
txset = 0;
menuset = 0;
foreach (var e in x.Root.Elements())
{
var name = e.Name.ToString();
switch (name)
{
case "FundItem":
ReadFundItem(e);
break;
case "FamilyAttend":
ReadFamilyAttend(e);
break;
case "ExtraQuestion":
ReadExtraQuestion(e);
break;
case "Text":
ReadText(e);
break;
case "YesNoQuestion":
ReadYesNoChoices(e);
break;
case "option":
ReadDropdownOption(e);
break;
case "Checkbox":
ReadCheckboxChoice(e);
break;
case "MenuItem":
ReadMenuItemChoice(e);
break;
case "MissionTripGoerId":
MissionTripGoerId = e.Value.ToInt();
break;
case "CreatingAccount":
CreatingAccount = e.Value.ToBool();
break;
case "SpecialTest":
ReadSpecialTest(e);
break;
default:
if (Util.SetPropertyFromText(this, TranslateName(name), e.Value) == false)
{
ErrorSignal.FromCurrentContext().Raise(new Exception("OnlineRegPerson Missing name:" + name));
Log($"Error:Missing({name})");
}
break;
}
}
}
示例13: RequiredAttribute
private static string RequiredAttribute(XmlReader reader, string attribute)
{
string result = OptionalAttribute(reader, attribute);
if(result == null)
{
throw Error.CouldNotFindRequiredAttribute(attribute, reader.ReadOuterXml());
}
return result;
}
示例14: DeserializeSection
protected override void DeserializeSection(XmlReader reader)
{
if (!reader.Read() || (reader.NodeType != XmlNodeType.Element))
{
throw new ConfigurationErrorsException("Expected to find element");
}
_rawXml = reader.ReadOuterXml();
}
示例15: ProcessDataReader
private void ProcessDataReader(XmlReader reader)
{
ResultsListBox.Items.Clear();
while (reader.Read())
{
ResultsListBox.Items.Add(reader.ReadOuterXml());
//MessageBox.Show(reader.ReadOuterXml());
}
reader.Close();
}