XmlReader.ReadElementContentAs Yöntem
Tanım
Geçerli öğeyi okur ve içeriği belirtilen türden bir nesne olarak döndürür.Reads the current element and returns the contents as an object of the type specified.
Aşırı Yüklemeler
ReadElementContentAs(Type, IXmlNamespaceResolver) |
Öğe içeriğini istenen tür olarak okur.Reads the element content as the requested type. |
ReadElementContentAs(Type, IXmlNamespaceResolver, String, String) |
Belirtilen yerel ad ve ad alanı URI 'sinin geçerli öğeyle eşleşip eşleşmediğini denetler ve öğe içeriğini istenen tür olarak okur.Checks that the specified local name and namespace URI matches that of the current element, then reads the element content as the requested type. |
ReadElementContentAs(Type, IXmlNamespaceResolver)
Öğe içeriğini istenen tür olarak okur.Reads the element content as the requested type.
public:
virtual System::Object ^ ReadElementContentAs(Type ^ returnType, System::Xml::IXmlNamespaceResolver ^ namespaceResolver);
public virtual object ReadElementContentAs (Type returnType, System.Xml.IXmlNamespaceResolver namespaceResolver);
abstract member ReadElementContentAs : Type * System.Xml.IXmlNamespaceResolver -> obj
override this.ReadElementContentAs : Type * System.Xml.IXmlNamespaceResolver -> obj
Public Overridable Function ReadElementContentAs (returnType As Type, namespaceResolver As IXmlNamespaceResolver) As Object
Parametreler
- returnType
- Type
Döndürülecek değerin türü.The type of the value to be returned.
Göz önünde .NET Framework 3,5 sürümü ile, returnType
parametrenin değeri artık DateTimeOffset tür olabilir.Note With the release of the .NET Framework 3.5, the value of the returnType
parameter can now be the DateTimeOffset type.
- namespaceResolver
- IXmlNamespaceResolver
IXmlNamespaceResolverTür dönüştürmesi ile ilgili ad alanı öneklerini çözümlemek için kullanılan nesne.An IXmlNamespaceResolver object that is used to resolve any namespace prefixes related to type conversion.
Döndürülenler
Öğe içeriği istenen türü belirtilmiş nesneye dönüştürüldü.The element content converted to the requested typed object.
Özel durumlar
XmlReaderÖğesi bir öğesinde konumlandırılmamış.The XmlReader is not positioned on an element.
-veya--or-
XmlReaderÖnceki bir zaman uyumsuz işlem tamamlanmadan önce bir yöntem çağrıldı.An XmlReader method was called before a previous asynchronous operation finished. Bu durumda, InvalidOperationException "zaman uyumsuz bir işlem zaten devam ediyor." iletisiyle oluşturulur.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."
Geçerli öğe alt öğeler içeriyor.The current element contains child elements.
-veya--or-
Öğe içeriği istenen türe dönüştürülemiyor.The element content cannot be converted to the requested type.
Yöntemi null
bağımsız değişkenlerle çağrılır.The method is called with null
arguments.
Oku Decimal.MaxValue
.Read Decimal.MaxValue
.
Örnekler
Aşağıdaki örnek, ReadElementContentAs düğümünün içeriğini okumak için yöntemini kullanır date
.The following example uses the ReadElementContentAs method to read the content of the date
node.
using (XmlReader reader = XmlReader.Create("dataFile.xml")) {
reader.ReadToFollowing("date");
DateTime date = (DateTime) reader.ReadElementContentAs(typeof(System.DateTime), null);
// 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 = CType(reader.ReadElementContentAs(GetType(System.DateTime), Nothing), DateTime)
' If the current culture is "en-US",
' this writes "Wednesday, January 8, 2003".
Console.WriteLine([date].ToLongDateString())
End Using
Örnek, dataFile.xml
dosyayı giriş olarak kullanır.The example uses the dataFile.xml
file as input.
<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>
Açıklamalar
Bu yöntem Başlangıç etiketini, öğesinin içeriğini okur ve okuyucunun bitiş öğesi etiketini geçmesinden sonra gider.This method reads the start tag, the contents of the element, and moves the reader past the end element tag. Varlıkları genişletir ve işleme talimatlarını ve açıklamalarını yoksayar.It expands entities and ignores processing instructions and comments. Öğesi yalnızca basit içerik içerebilir.The element can only contain simple content. Diğer bir deyişle, alt öğeleri olamaz.That is, it cannot have child elements.
Daha fazla bilgi için XmlReader başvuru sayfasının ve W3C XML şeması Bölüm 2: veri türleri önerisi konusunun açıklamalar bölümüne bakın.For more information, see the Remarks section of the XmlReader reference page and the W3C XML Schema Part 2: Datatypes recommendation.
Bu yöntemin zaman uyumsuz sürümü için bkz ReadElementContentAsAsync ..For the asynchronous version of this method, see ReadElementContentAsAsync.
Şunlara uygulanır
ReadElementContentAs(Type, IXmlNamespaceResolver, String, String)
Belirtilen yerel ad ve ad alanı URI 'sinin geçerli öğeyle eşleşip eşleşmediğini denetler ve öğe içeriğini istenen tür olarak okur.Checks that the specified local name and namespace URI matches that of the current element, then reads the element content as the requested type.
public:
virtual System::Object ^ ReadElementContentAs(Type ^ returnType, System::Xml::IXmlNamespaceResolver ^ namespaceResolver, System::String ^ localName, System::String ^ namespaceURI);
public virtual object ReadElementContentAs (Type returnType, System.Xml.IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI);
abstract member ReadElementContentAs : Type * System.Xml.IXmlNamespaceResolver * string * string -> obj
override this.ReadElementContentAs : Type * System.Xml.IXmlNamespaceResolver * string * string -> obj
Public Overridable Function ReadElementContentAs (returnType As Type, namespaceResolver As IXmlNamespaceResolver, localName As String, namespaceURI As String) As Object
Parametreler
- returnType
- Type
Döndürülecek değerin türü.The type of the value to be returned.
Göz önünde .NET Framework 3,5 sürümü ile, returnType
parametrenin değeri artık DateTimeOffset tür olabilir.Note With the release of the .NET Framework 3.5, the value of the returnType
parameter can now be the DateTimeOffset type.
- namespaceResolver
- IXmlNamespaceResolver
IXmlNamespaceResolverTür dönüştürmesi ile ilgili ad alanı öneklerini çözümlemek için kullanılan nesne.An IXmlNamespaceResolver object that is used to resolve any namespace prefixes related to type conversion.
- localName
- String
Öğenin yerel adı.The local name of the element.
- namespaceURI
- String
Öğenin ad alanı URI 'SI.The namespace URI of the element.
Döndürülenler
Öğe içeriği istenen türü belirtilmiş nesneye dönüştürüldü.The element content converted to the requested typed object.
Özel durumlar
XmlReaderÖğesi bir öğesinde konumlandırılmamış.The XmlReader is not positioned on an element.
-veya--or-
XmlReaderÖnceki bir zaman uyumsuz işlem tamamlanmadan önce bir yöntem çağrıldı.An XmlReader method was called before a previous asynchronous operation finished. Bu durumda, InvalidOperationException "zaman uyumsuz bir işlem zaten devam ediyor." iletisiyle oluşturulur.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."
Geçerli öğe alt öğeler içeriyor.The current element contains child elements.
-veya--or-
Öğe içeriği istenen türe dönüştürülemiyor.The element content cannot be converted to the requested type.
Yöntemi null
bağımsız değişkenlerle çağrılır.The method is called with null
arguments.
Belirtilen yerel ad ve ad alanı URI 'SI, okunan geçerli öğe ile eşleşmiyor.The specified local name and namespace URI do not match that of the current element being read.
Oku Decimal.MaxValue
.Read Decimal.MaxValue
.
Açıklamalar
Bu yöntem Başlangıç etiketini, öğesinin içeriğini okur ve okuyucunun bitiş öğesi etiketini geçmesinden sonra gider.This method reads the start tag, the contents of the element, and moves the reader past the end element tag. Varlıkları genişletir ve işleme talimatlarını ve açıklamalarını yoksayar.It expands entities and ignores processing instructions and comments. Öğesi yalnızca basit içerik içerebilir.The element can only contain simple content. Diğer bir deyişle, alt öğeleri olamaz.That is, it cannot have child elements.
Daha fazla bilgi için XmlReader başvuru sayfasının ve W3C XML şeması Bölüm 2: veri türleri önerisi konusunun açıklamalar bölümüne bakın.For more information, see the Remarks section of the XmlReader reference page and the W3C XML Schema Part 2: Datatypes recommendation.