本文整理汇总了C#中System.Xml.XmlWriter.WriteNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteNode方法的具体用法?C# XmlWriter.WriteNode怎么用?C# XmlWriter.WriteNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteXml
public void WriteXml(XmlWriter xmlWriter)
{
if (wsdl != null)
{
using (MemoryStream ms = new MemoryStream())
{
wsdl.Write(ms);
XmlDictionaryReaderQuotas quota = new XmlDictionaryReaderQuotas();
quota.MaxDepth = 32;
quota.MaxStringContentLength = 8192;
quota.MaxArrayLength = 16384;
quota.MaxBytesPerRead = 4096;
quota.MaxNameTableCharCount = 16384;
ms.Seek(0, SeekOrigin.Begin);
XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(ms, null, quota, null);
if ((reader.MoveToContent() == XmlNodeType.Element) && (reader.Name == "wsdl:definitions"))
{
xmlWriter.WriteNode(reader, false);
}
reader.Close();
}
}
}
示例2: fillXml
public void fillXml(XmlWriter xw)
{
using (XmlReader xr = XmlReader.Create(new StringReader(this.xmls)))
{
xr.ReadToFollowing(_xml_tag);
xw.WriteNode(xr, false);
}
}
示例3: WriteXml
public void WriteXml(XmlWriter writer)
{
writer.WriteAttributeString("index", index.ToString());
if (template != null)
{
writer.WriteStartElement("template");
writer.WriteNode(template.CreateReader(), true);
writer.WriteEndElement();
}
}
示例4: CopyNode
protected override void CopyNode(XmlReader reader, XmlWriter writer)
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "configuration")
{
writer.WriteStartElement("configuration");
writer.WriteAttributeString("version", "2");
reader.Read();
} else
{
writer.WriteNode(reader, true);
}
}
示例5: ExtractSdmxMessage
/// <summary>
/// Extract message from soap
/// </summary>
/// <param name="input">
/// The input
/// </param>
/// <param name="writer">
/// The writer
/// </param>
public static void ExtractSdmxMessage(Stream input, XmlWriter writer)
{
using (var reader = XmlReader.Create(input))
{
SdmxMessageUtil.FindSdmx(reader);
if (reader.EOF)
{
return;
}
writer.WriteStartDocument();
writer.WriteNode(reader, false);
}
}
示例6: using
void IXmlSerializable.WriteXml(XmlWriter writer)
{
writer.WriteAttributeString("Title", this.Title);
writer.WriteAttributeString("Row", this.Row.ToString());
writer.WriteAttributeString("Column", this.Column.ToString());
writer.WriteStartElement(XMLConstants.PROVISIONING_SCHEMA_PREFIX, "Contents", XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12);
using (XmlReader xr = new XmlNodeReader(this.Contents))
{
writer.WriteNode(xr, false);
}
writer.WriteEndElement();
}
示例7: WriteTo
public override void WriteTo(XmlWriter writer)
{
XmlReader r;
lock (this)
{
if (_reader == null) throw new Exception("The XmlReader has already been opened once and cannot be reset.");
r = _reader;
_reader = null;
}
if (r.ReadState == ReadState.Initial)
r.Read();
while (!r.EOF)
writer.WriteNode(r, true);
}
示例8: WriteAttributeValue
//public CustomSaml2SecurityTokenHandler(SecurityTokenHandlerConfiguration configuration)
//{
// SecurityTokenHandlerConfiguration handlerConfig = configuration ?? new SecurityTokenHandlerConfiguration
// {
// AudienceRestriction = {AudienceMode = AudienceUriMode.Never},
// CertificateValidationMode = X509CertificateValidationMode.None,
// RevocationMode = X509RevocationMode.NoCheck,
// MaxClockSkew = new TimeSpan(50000000),
// CertificateValidator = X509CertificateValidator.None
// };
// Configuration = handlerConfig;
//}
//public CustomSaml2SecurityTokenHandler()
// : this(null)
//{
//}
protected override void WriteAttributeValue(XmlWriter writer, string value, Saml2Attribute attribute)
{
var sb = new StringBuilder("<a>");
sb.Append(value);
sb.Append("</a>");
byte[] rawValue = new UTF8Encoding().GetBytes(sb.ToString());
using (
XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(rawValue,
XmlDictionaryReaderQuotas.Max))
{
reader.ReadStartElement("a");
while (reader.NodeType != XmlNodeType.EndElement ||
(reader.NodeType == XmlNodeType.EndElement && reader.Name != "a"))
{
writer.WriteNode(reader, false);
}
reader.ReadEndElement();
reader.Close();
}
}
示例9: SerializeToXmlElement
protected override bool SerializeToXmlElement(XmlWriter writer, String elementName)
{
bool dataToWrite = this.XmlElement != null;
if (dataToWrite && writer != null)
{
if (!String.Equals(elementName, ConfigurationStrings.XmlElement, StringComparison.Ordinal))
{
writer.WriteStartElement(elementName);
}
using (XmlNodeReader reader = new XmlNodeReader(this.XmlElement))
{
writer.WriteNode(reader, false);
}
if (!String.Equals(elementName, ConfigurationStrings.XmlElement, StringComparison.Ordinal))
{
writer.WriteEndElement();
}
}
return dataToWrite;
}
示例10: SignForm
private bool SignForm(XmlReader reader, XmlWriter writer)
{
if (!reader.IsStartElement("model"))
{
return false;
}
var doc = XDocument.Load(reader.ReadSubtree());
var formContents = GetFormContents(doc);
var submission = GetSubmission(doc);
if (submission != null)
{
submission.Element.SetAttributeValue("resource", submission.TargetUri.Replace(signaturePlaceholder, signature.GenerateSignature(formContents)));
}
reader.ReadEndElement();
writer.WriteNode(doc.CreateReader(), false);
writer.Flush();
return true;
}
示例11: WriteXml
public void WriteXml(XmlWriter xmlWriter)
{
if (this.wsdl != null)
{
using (MemoryStream stream = new MemoryStream())
{
this.wsdl.Write(stream);
XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas {
MaxDepth = 0x20,
MaxStringContentLength = 0x2000,
MaxArrayLength = 0x4000,
MaxBytesPerRead = 0x1000,
MaxNameTableCharCount = 0x4000
};
stream.Seek(0L, SeekOrigin.Begin);
XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, null, quotas, null);
if ((reader.MoveToContent() == XmlNodeType.Element) && (reader.Name == "wsdl:definitions"))
{
xmlWriter.WriteNode(reader, false);
}
reader.Close();
}
}
}
示例12: WriteTo
public override void WriteTo(XmlWriter w)
{
w.WriteNode(_navigator.ReadSubtree(), false);
}
示例13: WriteXml
/// <summary>
/// See <see cref="IXmlSerializable.WriteXml"/>.
/// </summary>
public void WriteXml(XmlWriter writer)
{
writer.WriteNode(this, false);
}
示例14: InvokeMethod
private void InvokeMethod(XmlWriter w, string methodName)
{
byte[] buffer = new byte[10];
switch (methodName)
{
case "WriteStartDocument":
w.WriteStartDocument();
break;
case "WriteStartElement":
w.WriteStartElement("root");
break;
case "WriteEndElement":
w.WriteEndElement();
break;
case "WriteStartAttribute":
w.WriteStartAttribute("attr");
break;
case "WriteEndAttribute":
w.WriteEndAttribute();
break;
case "WriteCData":
w.WriteCData("test");
break;
case "WriteComment":
w.WriteComment("test");
break;
case "WritePI":
w.WriteProcessingInstruction("name", "test");
break;
case "WriteEntityRef":
w.WriteEntityRef("e");
break;
case "WriteCharEntity":
w.WriteCharEntity('c');
break;
case "WriteSurrogateCharEntity":
w.WriteSurrogateCharEntity('\uDC00', '\uDBFF');
break;
case "WriteWhitespace":
w.WriteWhitespace(" ");
break;
case "WriteString":
w.WriteString("foo");
break;
case "WriteChars":
char[] charArray = new char[] { 'a', 'b', 'c', 'd' };
w.WriteChars(charArray, 0, 3);
break;
case "WriteRaw":
w.WriteRaw("<foo>bar</foo>");
break;
case "WriteBase64":
w.WriteBase64(buffer, 0, 9);
break;
case "WriteBinHex":
w.WriteBinHex(buffer, 0, 9);
break;
case "LookupPrefix":
string str = w.LookupPrefix("foo");
break;
case "WriteNmToken":
w.WriteNmToken("foo");
break;
case "WriteName":
w.WriteName("foo");
break;
case "WriteQualifiedName":
w.WriteQualifiedName("foo", "bar");
break;
case "WriteValue":
w.WriteValue(Int32.MaxValue);
break;
case "WriteAttributes":
XmlReader xr1 = ReaderHelper.Create(new StringReader("<root attr='test'/>"));
xr1.Read();
w.WriteAttributes(xr1, false);
break;
case "WriteNodeReader":
XmlReader xr2 = ReaderHelper.Create(new StringReader("<root/>"));
xr2.Read();
w.WriteNode(xr2, false);
break;
case "Flush":
w.Flush();
break;
default:
CError.Equals(false, "Unexpected param in testcase: {0}", methodName);
break;
}
}
示例15: WriteFeed
/// <summary>
/// Called by the runtime when all entities are written and contents needs to flushed to the underlying stream.
/// </summary>
/// <param name="writer">XmlWriter to which this feed will be serialized to</param>
public override void WriteFeed(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
_document.Add(_root);
// Write the </feed> end element.
writer.WriteNode(_document.CreateReader(), true);
writer.Flush();
}