XmlTextReader 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
의 새 인스턴스를 XmlTextReader초기화합니다.
오버로드
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
XmlTextReader()
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
의 새 인스턴스를 XmlTextReader초기화합니다.
protected:
XmlTextReader();
protected XmlTextReader();
Protected Sub New ()
추가 정보
적용 대상
XmlTextReader(String, XmlNodeType, XmlParserContext)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 문자열XmlNodeType을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다XmlParserContext.
public:
XmlTextReader(System::String ^ xmlFragment, System::Xml::XmlNodeType fragType, System::Xml::XmlParserContext ^ context);
public XmlTextReader(string xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext? context);
public XmlTextReader(string xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext context);
new System.Xml.XmlTextReader : string * System.Xml.XmlNodeType * System.Xml.XmlParserContext -> System.Xml.XmlTextReader
Public Sub New (xmlFragment As String, fragType As XmlNodeType, context As XmlParserContext)
매개 변수
- xmlFragment
- String
구문 분석할 XML 조각이 포함된 문자열입니다.
- fragType
- XmlNodeType
XmlNodeType XML 조각의 또한 조각 문자열에 포함될 수 있는 항목도 결정합니다. (아래 표를 참조하세요.)
- context
- XmlParserContext
XmlParserContext
xmlFragment 구문 분석할 값입니다. 여기에는 사용, 인코딩, 네임스페이스 범위, 현재 xml:lang및 범위가 xml:space 포함됩니다XmlNameTable.
예외
예제
다음 예제에서는 XML 조각을 구문 분석합니다. 네임스페이 XmlParserContext 스 확인을 처리하기 위해 해당 및 XmlNamespaceManager 해당 네임스페이스를 사용합니다.
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
//Create the XML fragment to be parsed.
string xmlFrag ="<book> " +
"<title>Pride And Prejudice</title>" +
"<bk:genre>novel</bk:genre>" +
"</book>";
//Create the XmlNamespaceManager.
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("bk", "urn:sample");
//Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
//Create the reader.
XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context);
//Parse the XML. If they exist, display the prefix and
//namespace URI of each element.
while (reader.Read()){
if (reader.IsStartElement()){
if (reader.Prefix==String.Empty)
{
Console.WriteLine("<{0}>", reader.LocalName);
}
else
{
Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName);
Console.WriteLine(" The namespace URI is " + reader.NamespaceURI);
}
}
}
//Close the reader.
reader.Close();
}
} // End class
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
'Create the XML fragment to be parsed.
Dim xmlFrag as string ="<book> " & _
"<title>Pride And Prejudice</title>" & _
"<bk:genre>novel</bk:genre>" & _
"</book>"
'Create the XmlNamespaceManager.
Dim nt as NameTable = new NameTable()
Dim nsmgr as XmlNamespaceManager = new XmlNamespaceManager(nt)
nsmgr.AddNamespace("bk", "urn:sample")
'Create the XmlParserContext.
Dim context as XmlParserContext = new XmlParserContext(nothing, nsmgr, nothing, XmlSpace.None)
'Create the reader.
Dim reader as XmlTextReader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context)
'Parse the XML. If they exist, display the prefix and
'namespace URI of each element.
while (reader.Read())
if (reader.IsStartElement())
if (reader.Prefix=String.Empty)
Console.WriteLine("<{0}>", reader.LocalName)
else
Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName)
Console.WriteLine(" The namespace URI is " + reader.NamespaceURI)
end if
end if
end while
'Close the reader.
reader.Close()
end sub
end class
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이 생성자는 지정된 문자열을 XML의 조각으로 구문 분석합니다. XML 조각이 요소 또는 특성인 경우 올바른 형식의 XML 문서에 대한 루트 수준 규칙을 무시할 수 있습니다. 이 생성자는 .에서 ReadInnerXml반환된 문자열을 처리할 수 있습니다.
다음 표에서는 판독기에서 각 노드 형식을 구문 분석하는 방법과 유효한 값을 fragType 나열합니다.
| XmlNodeType | 조각에 포함될 수 있음 |
|---|---|
| 요소 | 모든 유효한 요소 콘텐츠(예: 요소, 주석, 처리 지침, CDATA 섹션, 텍스트 및 엔터티 참조의 조합). XML 선언도 제공할 수 있습니다. 이렇게 하면 개체에서 설정하지 않고 XML 조각에 대한 인코딩을 지정할 수 XmlParserContext 있습니다. |
| 특성 | 특성의 값(따옴표 안의 부분)입니다. |
| 문서 | 전체 XML 문서의 내용입니다. 이렇게 하면 문서 수준 규칙이 적용됩니다. |
추가 정보
적용 대상
XmlTextReader(String, TextReader, XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 URL TextReader 을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다XmlNameTable.
public:
XmlTextReader(System::String ^ url, System::IO::TextReader ^ input, System::Xml::XmlNameTable ^ nt);
public XmlTextReader(string url, System.IO.TextReader input, System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : string * System.IO.TextReader * System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Public Sub New (url As String, input As TextReader, nt As XmlNameTable)
매개 변수
- input
- TextReader
TextReader 읽을 XML 데이터가 들어 있는 항목입니다.
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
예외
nt 값은 null.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이미 올바른 인코딩으로 설정되어 있다고 가정 TextReader 합니다. 이는 여러 부분으로 구성된 MIME 시나리오에서 스트림에서 일부 항목을 이미 읽은 클라이언트에서 사용됩니다.
추가 정보
적용 대상
XmlTextReader(String, Stream, XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 URL, 스트림 및 XmlNameTable을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다.
public:
XmlTextReader(System::String ^ url, System::IO::Stream ^ input, System::Xml::XmlNameTable ^ nt);
public XmlTextReader(string url, System.IO.Stream input, System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : string * System.IO.Stream * System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Public Sub New (url As String, input As Stream, nt As XmlNameTable)
매개 변수
- input
- Stream
읽을 XML 데이터가 포함된 스트림입니다.
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
예외
input 또는 nt 값이 .입니다null.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
추가 정보
적용 대상
XmlTextReader(Stream, XmlNodeType, XmlParserContext)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 스트림XmlNodeType을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다XmlParserContext.
public:
XmlTextReader(System::IO::Stream ^ xmlFragment, System::Xml::XmlNodeType fragType, System::Xml::XmlParserContext ^ context);
public XmlTextReader(System.IO.Stream xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext? context);
public XmlTextReader(System.IO.Stream xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext context);
new System.Xml.XmlTextReader : System.IO.Stream * System.Xml.XmlNodeType * System.Xml.XmlParserContext -> System.Xml.XmlTextReader
Public Sub New (xmlFragment As Stream, fragType As XmlNodeType, context As XmlParserContext)
매개 변수
- xmlFragment
- Stream
구문 분석할 XML 조각이 포함된 스트림입니다.
- fragType
- XmlNodeType
XmlNodeType XML 조각의 또한 조각에 포함할 수 있는 항목도 결정합니다. (아래 표를 참조하세요.)
- context
- XmlParserContext
XmlParserContext
xmlFragment 구문 분석할 값입니다. 여기에는 사용, 인코딩, 네임스페이스 범위, 현재 xml:lang및 범위가 xml:space 포함됩니다XmlNameTable.
예외
fragType 가 요소, 특성 또는 문서가 XmlNodeType아닌 경우
xmlFragment은 null입니다.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이 생성자는 지정된 문자열을 XML의 조각으로 구문 분석합니다. XML 조각이 요소 또는 특성인 경우 올바른 형식의 XML 문서에 대한 루트 수준 규칙을 무시할 수 있습니다.
다음 표에서는 에 대한 유효한 값을 나열합니다 fragType.
| XmlNodeType | 조각에 포함될 수 있음 |
|---|---|
Element |
모든 유효한 요소 콘텐츠(예: 요소, 주석, 처리 지침, CDATA 섹션, 텍스트 및 엔터티 참조의 조합). XML 선언도 제공할 수 있습니다. 이렇게 하면 개체에서 설정하지 않고 XML 조각에 대한 인코딩을 지정할 수 XmlParserContext 있습니다. |
Attribute |
특성의 값(따옴표 안의 부분)입니다. |
Document |
전체 XML 문서의 내용입니다. 이렇게 하면 문서 수준 규칙이 적용됩니다. |
판독기는 다음을 사용하여 스트림의 인코딩을 확인합니다.
XmlParserContext.Encoding 속성을 확인하여 인코딩을 확인합니다.
속성이
Encoding면 판독기는null스트림의 시작 부분에서 바이트 순서 표시를 확인합니다.속성이
Encodingnull있고 바이트 순서 표시를 찾을 수 없는 경우 판독기는 스트림이 UTF-8로 인코딩된 것으로 가정합니다.
추가 정보
적용 대상
XmlTextReader(String, TextReader)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 URL 및 .을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다 TextReader.
public:
XmlTextReader(System::String ^ url, System::IO::TextReader ^ input);
public XmlTextReader(string url, System.IO.TextReader input);
new System.Xml.XmlTextReader : string * System.IO.TextReader -> System.Xml.XmlTextReader
Public Sub New (url As String, input As TextReader)
매개 변수
- input
- TextReader
TextReader 읽을 XML 데이터가 들어 있는 항목입니다.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이미 올바른 인코딩으로 설정되어 있다고 가정 TextReader 합니다. 이는 여러 부분으로 구성된 MIME 시나리오에서 스트림에서 일부 항목을 이미 읽은 클라이언트에서 사용됩니다.
추가 정보
적용 대상
XmlTextReader(String, Stream)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 URL 및 스트림을 XmlTextReader 사용하여 클래스의 새 인스턴스를 초기화합니다.
public:
XmlTextReader(System::String ^ url, System::IO::Stream ^ input);
public XmlTextReader(string url, System.IO.Stream input);
new System.Xml.XmlTextReader : string * System.IO.Stream -> System.Xml.XmlTextReader
Public Sub New (url As String, input As Stream)
매개 변수
- input
- Stream
읽을 XML 데이터가 포함된 스트림입니다.
예외
input은 null입니다.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
추가 정보
적용 대상
XmlTextReader(String, XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 파일을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화하고 XmlNameTable.
public:
XmlTextReader(System::String ^ url, System::Xml::XmlNameTable ^ nt);
public XmlTextReader(string url, System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : string * System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Public Sub New (url As String, nt As XmlNameTable)
매개 변수
- url
- String
읽을 XML 데이터가 포함된 파일의 URL입니다.
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
예외
nt 값은 null.
지정된 파일을 찾을 수 없습니다.
파일 이름 또는 디렉터리의 일부를 찾을 수 없습니다.
url 은 빈 문자열입니다.
url 가 유효한 URI가 아닌 경우
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
추가 정보
적용 대상
XmlTextReader(Stream, XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 스트림을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다 XmlNameTable.
public:
XmlTextReader(System::IO::Stream ^ input, System::Xml::XmlNameTable ^ nt);
public XmlTextReader(System.IO.Stream input, System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : System.IO.Stream * System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Public Sub New (input As Stream, nt As XmlNameTable)
매개 변수
- input
- Stream
읽을 XML 데이터가 포함된 스트림입니다.
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
예외
input 또는 nt 값이 .입니다null.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
를 XmlTextReader 사용하여 System.Text.Encoding스트림을 디코딩합니다.
이름 테이블을 지정하는 경우 이 생성자는 해당 테이블에 이미 정의된 이름을 사용합니다.
추가 정보
적용 대상
XmlTextReader(XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 클래스를 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다 XmlNameTable.
protected:
XmlTextReader(System::Xml::XmlNameTable ^ nt);
protected XmlTextReader(System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Protected Sub New (nt As XmlNameTable)
매개 변수
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
추가 정보
적용 대상
XmlTextReader(String)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 파일을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다.
public:
XmlTextReader(System::String ^ url);
public XmlTextReader(string url);
new System.Xml.XmlTextReader : string -> System.Xml.XmlTextReader
Public Sub New (url As String)
매개 변수
예외
지정된 파일을 찾을 수 없습니다.
파일 이름 또는 디렉터리의 일부를 찾을 수 없습니다.
url 은 빈 문자열입니다.
url 가 유효한 URI가 아닌 경우
예제
다음 예제에서는 XML 파일을 읽고 각 노드를 표시합니다.
using System;
using System.IO;
using System.Xml;
public class Sample {
private const String filename = "items.xml";
public static void Main() {
XmlTextReader reader = null;
try {
// Load the reader with the data file and ignore all white space nodes.
reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None;
// Parse the file and display each of the nodes.
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
Console.Write("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.Write(reader.Value);
break;
case XmlNodeType.CDATA:
Console.Write("<![CDATA[{0}]]>", reader.Value);
break;
case XmlNodeType.ProcessingInstruction:
Console.Write("<?{0} {1}?>", reader.Name, reader.Value);
break;
case XmlNodeType.Comment:
Console.Write("<!--{0}-->", reader.Value);
break;
case XmlNodeType.XmlDeclaration:
Console.Write("<?xml version='1.0'?>");
break;
case XmlNodeType.Document:
break;
case XmlNodeType.DocumentType:
Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);
break;
case XmlNodeType.EntityReference:
Console.Write(reader.Name);
break;
case XmlNodeType.EndElement:
Console.Write("</{0}>", reader.Name);
break;
}
}
}
finally {
if (reader!=null)
reader.Close();
}
}
} // End class
Option Strict
Option Explicit
Imports System.IO
Imports System.Xml
'Reads an XML document
Public Class Sample
Private Const filename As String = "items.xml"
Public Shared Sub Main()
Dim reader As XmlTextReader = Nothing
Try
' Load the reader with the data file and ignore all white space nodes.
reader = New XmlTextReader(filename)
reader.WhitespaceHandling = WhitespaceHandling.None
' Parse the file and display each of the nodes.
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
Console.Write("<{0}>", reader.Name)
Case XmlNodeType.Text
Console.Write(reader.Value)
Case XmlNodeType.CDATA
Console.Write("<![CDATA[{0}]]>", reader.Value)
Case XmlNodeType.ProcessingInstruction
Console.Write("<?{0} {1}?>", reader.Name, reader.Value)
Case XmlNodeType.Comment
Console.Write("<!--{0}-->", reader.Value)
Case XmlNodeType.XmlDeclaration
Console.Write("<?xml version='1.0'?>")
Case XmlNodeType.Document
Case XmlNodeType.DocumentType
Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value)
Case XmlNodeType.EntityReference
Console.Write(reader.Name)
Case XmlNodeType.EndElement
Console.Write("</{0}>", reader.Name)
End Select
End While
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
End Class
이 예제에서는 파일을 items.xml입력으로 사용합니다.
<?xml version="1.0"?>
<!-- This is a sample XML document -->
<!DOCTYPE Items [<!ENTITY number "123">]>
<Items>
<Item>Test with an entity: &number;</Item>
<Item>test with a child element <more/> stuff</Item>
<Item>test with a CDATA section <![CDATA[<456>]]> def</Item>
<Item>Test with an char entity: A</Item>
<!-- Fourteen chars in this element.-->
<Item>1234567890ABCD</Item>
</Items>
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
파일이 액세스 자격 증명이 필요한 리소스에 있는 경우 속성을 사용하여 XmlResolver 필요한 자격 증명을 지정합니다.
메모
.NET Framework 버전 1.1에서 부분적으로 신뢰할 수 있는 코드는 속성을 설정할 XmlResolver 수 없습니다. 해결 방법은 필요한 자격 증명을 사용하여 XmlUrlResolver 만들고 메서드에 URI를 XmlUrlResolver.GetEntity 전달한 다음 결과 Stream 개체를 XmlTextReader 사용하여 생성하는 것입니다. 해결 방법은 다음 C# 코드에 설명되어 있습니다.
// Create a resolver with the necessary credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
NetworkCredential nc = new NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword, SecurelyStoredDomain);
resolver.Credentials = nc;
// Get a Stream object containing the XML file.
Uri myUri = new Uri ("http://myServer/data/books.xml");
Stream s=(Stream)resolver.GetEntity(myUri, null, typeof(Stream));
// Construct a reader using the Stream object.
XmlTextReader reader = new XmlTextReader(s);
추가 정보
적용 대상
XmlTextReader(TextReader)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 클래스를 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다 TextReader.
public:
XmlTextReader(System::IO::TextReader ^ input);
public XmlTextReader(System.IO.TextReader input);
new System.Xml.XmlTextReader : System.IO.TextReader -> System.Xml.XmlTextReader
Public Sub New (input As TextReader)
매개 변수
- input
- TextReader
TextReader 읽을 XML 데이터가 들어 있는 항목입니다.
예제
다음 예제에서는 클래스를 사용 하 여 개체에 XmlTextReader XML 문자열을 로드 합니다 StringReader .
using System;
using System.IO;
using System.Xml;
public class Sample {
public static void Main() {
string xmlData =
@"<book>
<title>Oberon's Legacy</title>
<price>5.95</price>
</book>";
// Create the reader.
XmlTextReader reader = new XmlTextReader(new StringReader(xmlData));
reader.WhitespaceHandling = WhitespaceHandling.None;
// Display each element node.
while (reader.Read()){
switch (reader.NodeType){
case XmlNodeType.Element:
Console.Write("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.Write(reader.Value);
break;
case XmlNodeType.EndElement:
Console.Write("</{0}>", reader.Name);
break;
}
}
// Close the reader.
reader.Close();
}
} // End class
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim xmlData as string
xmlData = "<book>" & _
" <title>Oberon's Legacy</title>" & _
" <price>5.95</price>" & _
"</book>"
' Create the reader.
Dim reader as XmlTextReader = new XmlTextReader(new StringReader(xmlData))
reader.WhitespaceHandling = WhitespaceHandling.None
' Display each element node.
while reader.Read()
select case reader.NodeType
case XmlNodeType.Element
Console.Write("<{0}>", reader.Name)
case XmlNodeType.Text
Console.Write(reader.Value)
case XmlNodeType.EndElement
Console.Write("</{0}>", reader.Name)
end select
end while
' Close the reader.
reader.Close()
end sub
end class
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이미 올바른 인코딩으로 설정되어 있다고 가정 TextReader 합니다. 이는 여러 부분으로 구성된 MIME 시나리오에서 스트림에서 일부 항목을 이미 읽은 클라이언트에서 사용됩니다.
추가 정보
적용 대상
XmlTextReader(Stream)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 스트림을 사용하여 클래스의 XmlTextReader 새 인스턴스를 초기화합니다.
public:
XmlTextReader(System::IO::Stream ^ input);
public XmlTextReader(System.IO.Stream input);
new System.Xml.XmlTextReader : System.IO.Stream -> System.Xml.XmlTextReader
Public Sub New (input As Stream)
매개 변수
- input
- Stream
읽을 XML 데이터가 포함된 스트림입니다.
예외
input은 null입니다.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
를 XmlTextReader 사용하여 System.Text.Encoding스트림을 디코딩합니다.
추가 정보
적용 대상
XmlTextReader(TextReader, XmlNameTable)
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
- Source:
- XmlTextReader.cs
지정된 클래스와 .를 사용하여 클래스의 XmlTextReader 새 인스턴스를 TextReader 초기화합니다 XmlNameTable.
public:
XmlTextReader(System::IO::TextReader ^ input, System::Xml::XmlNameTable ^ nt);
public XmlTextReader(System.IO.TextReader input, System.Xml.XmlNameTable nt);
new System.Xml.XmlTextReader : System.IO.TextReader * System.Xml.XmlNameTable -> System.Xml.XmlTextReader
Public Sub New (input As TextReader, nt As XmlNameTable)
매개 변수
- input
- TextReader
TextReader 읽을 XML 데이터가 들어 있는 항목입니다.
- nt
- XmlNameTable
XmlNameTable 사용할 수 있습니다.
예외
nt 값은 null.
설명
메모
새 기능을 활용하기 위해 XmlReader 메서드를 사용하여 XmlReader.Create 인스턴스를 만드는 것이 좋습니다.
이미 올바른 인코딩으로 설정되어 있다고 가정 TextReader 합니다. 이는 여러 부분으로 구성된 MIME 시나리오에서 스트림에서 일부 항목을 이미 읽은 클라이언트에서 사용됩니다.