Share via


MoveToContent Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Checks whether the current node is a content (non-white space text, CDATA, Element, EndElement, EntityReference, or EndEntity) node. If the node is not a content node, the reader skips ahead to the next content node or end of file. It skips over nodes of the following type: ProcessingInstruction, DocumentType, Comment, Whitespace, or SignificantWhitespace.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

Syntax

'Declaration
Public Overridable Function MoveToContent As XmlNodeType
public virtual XmlNodeType MoveToContent()
public:
virtual XmlNodeType MoveToContent()
abstract MoveToContent : unit -> XmlNodeType 
override MoveToContent : unit -> XmlNodeType 
public function MoveToContent() : XmlNodeType

Return Value

Type: System.Xml. . :: . .XmlNodeType
The NodeType of the current node found by the method or XmlNodeType.None if the reader has reached the end of the input stream.

Remarks

If the current node is an attribute node, this method moves the reader back to the element that owns the attribute.

For the asynchronous version of this method, see MoveToContentAsync.

Examples

This is useful when you want to write code that can skip over random XML markup without breaking. For example, suppose you have the following code:

This code can handle the following inputs without breaking:

<price>123.4</price>

and

<?xml version="1.0"><!DOCTYPE price SYSTEM
  "abc"><price>123.4</price>

and

<?xml version="1.0"><!DOCTYPE price SYSTEM "abc"
  [<!ENTTIY p
  "123.4">]><price>&p;</price>

and

<!-- some test comment --><?processing
  instruction?><price>123.4</price>

.NET Framework Security

See Also

Reference

XmlReader Class

System.Xml Namespace