本文整理汇总了C#中System.Xml.XmlWriter.WriteFullEndElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteFullEndElement方法的具体用法?C# XmlWriter.WriteFullEndElement怎么用?C# XmlWriter.WriteFullEndElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteFullEndElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
internal override void WriteTo(XmlWriter xml)
{
if (xml == null)
return;
xml.WriteComment(SR.GetString(SR.ServiceNameFromClient));
xml.WriteElementString("ServiceName", this.serviceBindingNameSentByClient);
xml.WriteComment(SR.GetString(SR.ServiceNameOnService));
xml.WriteStartElement("ServiceNameCollection");
if (this.serviceNameCollectionConfiguredOnServer == null || this.serviceNameCollectionConfiguredOnServer.Count < 1)
{
xml.WriteElementString("ServiceName", this.defaultServiceBindingNameOfServer);
}
else
{
foreach (string serviceName in this.serviceNameCollectionConfiguredOnServer)
{
xml.WriteElementString("ServiceName", serviceName);
}
}
xml.WriteFullEndElement();
}
示例2: WriteElement
/// <summary>
/// 寫XML元素
/// </summary>
/// <param name="write">XmlWriter</param>
/// <param name="elementName">元素名稱</param>
/// <param name="value">元素的值</param>
public void WriteElement(XmlWriter writer, string elementName, string value)
{
if (string.IsNullOrEmpty(value) || value.Length == 0)
{
writer.WriteStartElement(elementName);
writer.WriteFullEndElement();
}
else
{
writer.WriteElementString(elementName, value);
}
}
示例3: WriteXamlTextSegment
//.........这里部分代码省略.........
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
continue;
}
}
else if (nextElement != null)
{
//
TextElementEditingBehaviorAttribute att = (TextElementEditingBehaviorAttribute)Attribute.GetCustomAttribute(nextElement.GetType(), typeof(TextElementEditingBehaviorAttribute));
if (att != null && !att.IsTypographicOnly)
{
if (IsPartialNonTypographic(textReader, rangeEnd))
{
// Add pointer to ignore list
ITextPointer ptr = textReader.CreatePointer();
ptr.MoveToElementEdge(ElementEdge.BeforeEnd);
ignoreList.Add(ptr.Offset);
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
continue;
}
}
}
elementLevel++;
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
WriteStartXamlElement(/*range:*/null, textReader, xmlWriter, xamlTypeMapper, /*reduceElement:*/wpfPayload == null, preserveTextElements);
break;
case TextPointerContext.ElementEnd:
// Don't write Hyperlink end element if Hyperlink include the invalid
// in case of having a UiElement except Image or stated the range end
// before the end position of the Hyperlink or Hyperlink opening tag is
// skipped from WriteOpeningTags by selecting of the partial of Hyperlink.
if (ignoreWriteHyperlinkEnd && (textReader.GetAdjacentElement(LogicalDirection.Forward) is Hyperlink))
{
// Reset the flag to keep walk up the next Hyperlink tag
ignoreWriteHyperlinkEnd = false;
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
continue;
}
// Check the ignore list
ITextPointer endPointer = textReader.CreatePointer();
endPointer.MoveToElementEdge(ElementEdge.BeforeEnd); //
if (ignoreList.Contains(endPointer.Offset))
{
ignoreList.Remove(endPointer.Offset);
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
continue;
}
elementLevel--;
if (TextSchema.IsBreak(textReader.ParentType))
{
// For LineBreak, etc. use empty element syntax
xmlWriter.WriteEndElement();
}
else
{ //
// For all other textelements use explicit closing tag.
xmlWriter.WriteFullEndElement();
}
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
break;
case TextPointerContext.Text:
int textLength = textReader.GetTextRunLength(LogicalDirection.Forward);
char[] text = new Char[textLength];
textLength = TextPointerBase.GetTextWithLimit(textReader, LogicalDirection.Forward, text, 0, textLength, rangeEnd);
// XmlWriter will throw an ArgumentException if text contains
// any invalid surrogates, so strip them out now.
textLength = StripInvalidSurrogateChars(text, textLength);
xmlWriter.WriteChars(text, 0, textLength);
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
break;
case TextPointerContext.EmbeddedElement:
object embeddedObject = textReader.GetAdjacentElement(LogicalDirection.Forward);
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
WriteEmbeddedObject(embeddedObject, xmlWriter, wpfPayload);
break;
default:
Invariant.Assert(false, "unexpected value of runType");
textReader.MoveToNextContextPosition(LogicalDirection.Forward);
break;
}
}
}
示例4: WriteElementTo
// This method is copied from System.Xml.Linq.ElementWriter.WriteElement but adapted to DOM
private static void WriteElementTo(XmlWriter writer, XmlElement e)
{
XmlNode root = e;
XmlNode n = e;
while (true)
{
e = n as XmlElement;
// Only use the inlined write logic for XmlElement, not for derived classes
if (e != null && e.GetType() == typeof(XmlElement))
{
// Write the element
e.WriteStartElement(writer);
// Write the element's content
if (e.IsEmpty)
{
// No content; use a short end element <a />
writer.WriteEndElement();
}
else if (e._lastChild == null)
{
// No actual content; use a full end element <a></a>
writer.WriteFullEndElement();
}
else
{
// There are child node(s); move to first child
n = e.FirstChild;
Debug.Assert(n != null);
continue;
}
}
else
{
// Use virtual dispatch (might recurse)
n.WriteTo(writer);
}
// Go back to the parent after writing the last child
while (n != root && n == n.ParentNode.LastChild)
{
n = n.ParentNode;
Debug.Assert(n != null);
writer.WriteFullEndElement();
}
if (n == root)
break;
n = n.NextSibling;
Debug.Assert(n != null);
}
}
示例5: WriteNil
private void WriteNil(XmlWriter writer)
{
writer.WriteStartElement("nil");
writer.WriteFullEndElement();
}
示例6: WriteShallowNode
private static void WriteShallowNode(XmlReader reader, XmlWriter writer)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
if (reader.IsEmptyElement)
{
writer.WriteEndElement();
}
return;
case XmlNodeType.Text:
writer.WriteString(reader.Value);
return;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
return;
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
return;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
return;
case XmlNodeType.DocumentType:
writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
return;
case XmlNodeType.Whitespace:
writer.WriteWhitespace(reader.Value);
return;
case XmlNodeType.SignificantWhitespace:
writer.WriteWhitespace(reader.Value);
return;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
return;
case XmlNodeType.XmlDeclaration:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
return;
}
throw new InvalidOperationException("Invalid node");
}
示例7: WriteXml
void WriteXml(XmlWriter writer)
{
CommonUtility.AssertNotNull("writer", writer);
writer.WriteComment(SR.ExceptionOccurred);
writer.WriteStartElement("RequestResult");
writer.WriteElementString("HTTPStatusCode", Convert.ToString(this.HttpStatusCode, CultureInfo.InvariantCulture));
writer.WriteElementString("HttpStatusMessage", this.HttpStatusMessage);
writer.WriteElementString("TargetLocation", this.TargetLocation.ToString());
// Headers
writer.WriteElementString("ServiceRequestID", this.ServiceRequestID);
writer.WriteElementString("ContentMd5", this.ContentMd5);
writer.WriteElementString("Etag", this.Etag);
writer.WriteElementString("RequestDate", this.RequestDate);
// Dates - using RFC 1123 pattern
writer.WriteElementString("StartTime", this.StartTime.ToUniversalTime().ToString("R", CultureInfo.InvariantCulture));
writer.WriteElementString("EndTime", this.EndTime.ToUniversalTime().ToString("R", CultureInfo.InvariantCulture));
// Extended info
if (this.ExtendedErrorInformation != null)
{
this.ExtendedErrorInformation.WriteXml(writer);
}
else
{
// Write empty
writer.WriteStartElement(Constants.ErrorRootElement);
writer.WriteFullEndElement();
}
#if WINDOWS_RT || ASPNET_K
// Exception
if (this.ExceptionInfo != null)
{
this.ExceptionInfo.WriteXml(writer);
}
else
{
// Write empty
writer.WriteStartElement("ExceptionInfo");
writer.WriteFullEndElement();
}
#endif
// End RequestResult
writer.WriteEndElement();
}
示例8: BuildSubtree
internal void BuildSubtree(XmlReader reader, XmlWriter writer)
{
string ns = "http://www.w3.org/2000/xmlns/";
ReadState readState = reader.ReadState;
if ((readState != ReadState.Initial) && (readState != ReadState.Interactive))
{
throw new ArgumentException(Res.GetString("Xml_InvalidOperation"), "reader");
}
int num = 0;
if (readState == ReadState.Initial)
{
if (!reader.Read())
{
return;
}
num++;
}
do
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
{
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
bool isEmptyElement = reader.IsEmptyElement;
while (reader.MoveToNextAttribute())
{
if (reader.NamespaceURI == ns)
{
if (reader.Prefix.Length == 0)
{
writer.WriteAttributeString("", "xmlns", ns, reader.Value);
}
else
{
writer.WriteAttributeString("xmlns", reader.LocalName, ns, reader.Value);
}
}
else
{
writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteString(reader.Value);
writer.WriteEndAttribute();
}
}
reader.MoveToElement();
if (isEmptyElement)
{
writer.WriteEndElement();
}
else
{
num++;
}
break;
}
case XmlNodeType.Attribute:
if (reader.NamespaceURI != ns)
{
writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteString(reader.Value);
writer.WriteEndAttribute();
break;
}
if (reader.Prefix.Length != 0)
{
writer.WriteAttributeString("xmlns", reader.LocalName, ns, reader.Value);
break;
}
writer.WriteAttributeString("", "xmlns", ns, reader.Value);
break;
case XmlNodeType.Text:
case XmlNodeType.CDATA:
writer.WriteString(reader.Value);
break;
case XmlNodeType.EntityReference:
reader.ResolveEntity();
break;
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.LocalName, reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
writer.WriteString(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
num--;
break;
}
}
//.........这里部分代码省略.........
示例9: WriteNodeAsync
// Writes the content (inner XML) of the current node into the provided XmlWriter.
private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
{
int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth))
{
switch (this.NodeType)
{
case XmlNodeType.Element:
xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
xtw.WriteAttributes(this, defattr);
if (this.IsEmptyElement)
{
xtw.WriteEndElement();
}
break;
case XmlNodeType.Text:
xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false));
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false));
break;
case XmlNodeType.CDATA:
xtw.WriteCData(this.Value);
break;
case XmlNodeType.EntityReference:
xtw.WriteEntityRef(this.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
xtw.WriteProcessingInstruction(this.Name, this.Value);
break;
case XmlNodeType.DocumentType:
xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
break;
case XmlNodeType.Comment:
xtw.WriteComment(this.Value);
break;
case XmlNodeType.EndElement:
xtw.WriteFullEndElement();
break;
}
}
if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
{
await ReadAsync().ConfigureAwait(false);
}
}
示例10: WriteShallowNode
public static void WriteShallowNode(XmlReader reader, XmlWriter writer)
{
//Console.WriteLine("{0}: {1}", reader.NodeType, reader.Name);
switch(reader.NodeType) {
case XmlNodeType.Element:
writer.WriteStartElement(reader.Prefix , reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
if(reader.IsEmptyElement)
writer.WriteEndElement();
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value);
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
writer.WriteWhitespace(reader.Value);
break;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
break;
case XmlNodeType.EntityReference:
writer.WriteEntityRef(reader.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.DocumentType:
writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
break;
}
}
示例11: BuildSubtree
internal void BuildSubtree(XmlReader reader, XmlWriter writer) {
// important (perf) string literal...
string xmlnsUri = XmlReservedNs.NsXmlNs; // http://www.w3.org/2000/xmlns/
ReadState readState = reader.ReadState;
if (readState != ReadState.Initial
&& readState != ReadState.Interactive) {
throw new ArgumentException(Res.GetString(Res.Xml_InvalidOperation), "reader");
}
int level = 0;
if ( readState == ReadState.Initial ) {
if( !reader.Read() )
return;
level++; // if start in initial, read everything (not just first)
}
do {
switch (reader.NodeType) {
case XmlNodeType.Element:
writer.WriteStartElement( reader.Prefix, reader.LocalName, reader.NamespaceURI );
bool isEmptyElement = reader.IsEmptyElement;
while (reader.MoveToNextAttribute()) {
if ((object) reader.NamespaceURI == (object) xmlnsUri) {
if (reader.Prefix.Length == 0) {
// Default namespace declaration "xmlns"
Debug.Assert(reader.LocalName == "xmlns");
writer.WriteAttributeString( "", "xmlns", xmlnsUri, reader.Value );
}
else {
Debug.Assert(reader.Prefix == "xmlns");
writer.WriteAttributeString( "xmlns", reader.LocalName, xmlnsUri, reader.Value );
}
}
else {
writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteString(reader.Value);
writer.WriteEndAttribute();
}
}
reader.MoveToElement();
if (isEmptyElement) {
// there might still be a value, if there is a default value specified in the schema
writer.WriteEndElement();
}
else {
level++;
}
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
//should not read beyond the level of the reader's original position.
level--;
break;
case XmlNodeType.Text:
case XmlNodeType.CDATA:
writer.WriteString( reader.Value );
break;
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Whitespace:
//
writer.WriteString( reader.Value );
break;
case XmlNodeType.Comment:
writer.WriteComment( reader.Value );
break;
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction( reader.LocalName , reader.Value);
break;
case XmlNodeType.EntityReference:
reader.ResolveEntity(); //
break;
case XmlNodeType.EndEntity:
case XmlNodeType.None:
case XmlNodeType.DocumentType:
case XmlNodeType.XmlDeclaration:
break;
case XmlNodeType.Attribute:
if ((object) reader.NamespaceURI == (object) xmlnsUri) {
if (reader.Prefix.Length == 0) {
// Default namespace declaration "xmlns"
Debug.Assert(reader.LocalName == "xmlns");
writer.WriteAttributeString( "", "xmlns", xmlnsUri, reader.Value );
}
else {
Debug.Assert(reader.Prefix == "xmlns");
writer.WriteAttributeString( "xmlns", reader.LocalName, xmlnsUri, reader.Value );
}
}
else {
writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteString(reader.Value);
writer.WriteEndAttribute();
}
break;
}
}
while( reader.Read() && ( level > 0 ) );
}
示例12: PassNodeThrough
//copies from example
private void PassNodeThrough(XmlReader reader, XmlWriter writer)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
if (reader.IsEmptyElement)
{
writer.WriteEndElement();
}
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value);
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
writer.WriteWhitespace(reader.Value);
break;
case XmlNodeType.CDATA:
writer.WriteCData(reader.Value);
break;
case XmlNodeType.EntityReference:
writer.WriteEntityRef(reader.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.DocumentType:
writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
break;
}
}
示例13: WriteSearchpaths
static void WriteSearchpaths(XmlWriter writer)
{
XmlSerializer xs = new XmlSerializer(typeof (SearchPathInfo));
writer.WriteStartElement("Searchpaths");
foreach (var kvp in s_searchpaths)
{
if (kvp.Value.Count == 0)
continue;
writer.WriteStartElement("Entry");
writer.WriteElementString("Key", kvp.Key);
writer.WriteStartElement("Paths");
foreach (var path in kvp.Value)
xs.Serialize(writer, path);
writer.WriteEndElement();
writer.WriteFullEndElement();
}
writer.WriteFullEndElement();
}
示例14: WriteDictionary
static void WriteDictionary(XmlWriter writer)
{
XmlSerializer xs = new XmlSerializer(typeof (RBFDictEntry));
writer.WriteStartElement("Dictionary");
foreach (var kvp in s_dictionary)
{
if (kvp.Value.Options.Count == 0)
continue;
xs.Serialize(writer, kvp.Value);
}
writer.WriteFullEndElement();
}
示例15: WriteTo
public override void WriteTo(XmlWriter w)
{
w.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
if (this.HasAttributes)
{
XmlAttributeCollection attributes = this.Attributes;
for (int i = 0; i < attributes.Count; i++)
{
attributes[i].WriteTo(w);
}
}
if (this.IsEmpty)
{
w.WriteEndElement();
}
else
{
this.WriteContentTo(w);
w.WriteFullEndElement();
}
}