XmlReader.ReadElementContentAsDateTime 메서드

정의

현재 요소를 읽고 콘텐츠를 DateTime 개체로 반환합니다.

오버로드

ReadElementContentAsDateTime()

현재 요소를 읽고 콘텐츠를 DateTime 개체로 반환합니다.

ReadElementContentAsDateTime(String, String)

지정된 로컬 이름과 네임스페이스 URI가 현재 요소의 로컬 이름 및 네임스페이스 URI와 일치하는지 확인한 다음 현재 요소를 읽고 콘텐츠를 DateTime 개체로 반환합니다.

ReadElementContentAsDateTime()

현재 요소를 읽고 콘텐츠를 DateTime 개체로 반환합니다.

public:
 virtual DateTime ReadElementContentAsDateTime();
public virtual DateTime ReadElementContentAsDateTime ();
abstract member ReadElementContentAsDateTime : unit -> DateTime
override this.ReadElementContentAsDateTime : unit -> DateTime
Public Overridable Function ReadElementContentAsDateTime () As DateTime

반환

DateTime

요소 콘텐츠에 해당하는 DateTime 개체입니다.

예외

XmlReader가 요소에 배치되지 않은 경우

또는

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

현재 요소에 자식 요소가 포함된 경우

또는

요소 콘텐츠를 DateTime 개체로 변환할 수 없는 경우

메서드가 null 인수를 사용하여 호출된 경우

예제

다음 예제에서는 메서드를 ReadElementContentAsDateTime 사용하여 요소의 date 내용을 읽습니다.

using (XmlReader reader = XmlReader.Create("dataFile.xml")) {
     reader.ReadToFollowing("date");
     DateTime date = reader.ReadElementContentAsDateTime();
  
     // If the current culture is "en-US",
     // this writes "Wednesday, January 8, 2003".
     Console.WriteLine(date.ToLongDateString());
}
Using reader As XmlReader = XmlReader.Create("dataFile.xml")
  reader.ReadToFollowing("date")
  Dim [date] As DateTime = reader.ReadElementContentAsDateTime()
            
  ' If the current culture is "en-US",
  ' this writes "Wednesday, January 8, 2003".
  Console.WriteLine([date].ToLongDateString())
End Using

이 예제에서는 dataFile.xml 파일을 입력으로 사용합니다.

<root>
  <stringValue>
     <!--comment-->
     <?some pi?>
      text value of the element.
  </stringValue>
  <longValue>270000000000001</longValue>
  <number>0</number>
  <double>2E10</double>
  <date>2003-01-08T15:00:00-00:00</date>
</root>

설명

이 메서드는 시작 태그, 요소의 내용을 읽고 판독기를 끝 요소 태그를 지나 이동합니다. 엔터티를 확장하고 처리 지침 및 주석을 무시합니다. 요소는 간단한 콘텐츠만 포함할 수 있습니다. 즉, 자식 요소를 가질 수 없습니다.

콘텐츠를 입력 xsd:dateTime하면 판독기는 받은 편지 DateTime 하지 않은 개체를 반환합니다. 콘텐츠를 입력xsd:dateTime하지 않으면 판독기는 W3C XML 스키마 2부: Datatypes 권장 사항에 정의된 규칙에 따라 개체로 변환 DateTime 하려고 시도합니다.

참고

콘텐츠 형식이 DateTime.Year로 지정된 경우 xsd:gMonthDay 값을 사용할 수 없습니다. XmlReader 이 경우 항상 값을 1904로 설정합니다 DateTime.Year .

자세한 내용은 XmlReader 참조 페이지의 설명 섹션을 참조하세요.

적용 대상

ReadElementContentAsDateTime(String, String)

지정된 로컬 이름과 네임스페이스 URI가 현재 요소의 로컬 이름 및 네임스페이스 URI와 일치하는지 확인한 다음 현재 요소를 읽고 콘텐츠를 DateTime 개체로 반환합니다.

public:
 virtual DateTime ReadElementContentAsDateTime(System::String ^ localName, System::String ^ namespaceURI);
public virtual DateTime ReadElementContentAsDateTime (string localName, string namespaceURI);
abstract member ReadElementContentAsDateTime : string * string -> DateTime
override this.ReadElementContentAsDateTime : string * string -> DateTime
Public Overridable Function ReadElementContentAsDateTime (localName As String, namespaceURI As String) As DateTime

매개 변수

localName
String

요소의 로컬 이름입니다.

namespaceURI
String

요소의 네임스페이스 URI입니다.

반환

DateTime

요소 콘텐츠에 해당하는 DateTime 개체입니다.

예외

XmlReader가 요소에 배치되지 않은 경우

또는

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

현재 요소에 자식 요소가 포함된 경우

또는

요소 콘텐츠를 요청한 형식으로 변환할 수 없는 경우

메서드가 null 인수를 사용하여 호출된 경우

지정한 로컬 이름과 네임스페이스 URI가 읽고 있는 현재 요소의 로컬 이름 및 네임스페이스 URI와 일치하지 않는 경우

설명

이 메서드는 시작 태그, 요소의 내용을 읽고 판독기를 끝 요소 태그를 지나 이동합니다. 엔터티를 확장하고 처리 지침 및 주석을 무시합니다. 요소는 간단한 콘텐츠만 포함할 수 있습니다. 즉, 자식 요소를 가질 수 없습니다.

콘텐츠를 입력 xsd:dateTime하면 판독기는 받은 편지 DateTime 하지 않은 개체를 반환합니다. 콘텐츠를 입력xsd:dateTime하지 않으면 판독기는 W3C XML 스키마 2부: Datatypes 권장 사항에 정의된 규칙에 따라 개체로 변환 DateTime 하려고 시도합니다.

참고

콘텐츠 형식이 DateTime.Year로 지정된 경우 xsd:gMonthDay 값을 사용할 수 없습니다. XmlReader 이 경우 항상 값을 1904로 설정합니다 DateTime.Year .

자세한 내용은 XmlReader 참조 페이지의 설명 섹션을 참조하세요.

적용 대상