XmlReader.ReadElementString メソッド ()
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlReader Dim returnValue As String returnValue = instance.ReadElementString
読み取られた要素内に格納されているテキスト。要素が空 (<item></item> または <item/>) の場合は、空の文字列。


これは、単純なテキストだけの要素を読み取るためのヘルパー メソッドです。MoveToContent を呼び出して、次のコンテンツ ノードを検索してから、その値を単純文字列として解析します。
XML、<name>Arlene Huff</name>、ReadElementString を使用すると、要素が処理され、文字列 Arlene Huff が返されます。
このメソッドは name 要素内のマークアップ (子要素、コメント、処理命令など) を処理できませんが、複数の隣接したテキスト ブロックと CDATA ブロックを連結できます。

ReadElementString を使用して、要素ノードの内容を読み取る例を次に示します。
Imports System Imports System.Xml public class Sample private const filename as string = "book.xml" public shared Sub Main() Dim reader as XmlTextReader = Nothing try ' Load the file and ignore all white space. reader = new XmlTextReader(filename) reader.WhitespaceHandling = WhitespaceHandling.None ' Moves the reader to the root element. reader.MoveToContent() ' Read the title and price elements. Console.WriteLine("Content of the title element: {0}", reader.ReadElementString()) Console.WriteLine("Content of the price element: {0}", reader.ReadElementString()) finally if Not reader Is Nothing reader.Close() End if End try End Sub End class
using System; using System.Xml; public class Sample { private const String filename = "book.xml"; public static void Main() { XmlTextReader reader = null; try { // Load the file and ignore all white space. reader = new XmlTextReader(filename); reader.WhitespaceHandling = WhitespaceHandling.None; // Moves the reader to the root element. reader.MoveToContent(); // Read the title and price elements. Console.WriteLine("Content of the title element: {0}", reader.ReadElementString()); Console.WriteLine("Content of the price element: {0}", reader.ReadElementString());; } finally { if (reader!=null) reader.Close(); } } } // End class
#using <System.Xml.dll> using namespace System; using namespace System::Xml; int main() { String^ filename = "book.xml"; XmlTextReader^ reader = nullptr; try { // Load the file and ignore all white space. reader = gcnew XmlTextReader( filename ); reader->WhitespaceHandling = WhitespaceHandling::None; // Moves the reader to the root element. reader->MoveToContent(); // Read the title and price elements. Console::WriteLine( "Content of the title element: {0}", reader->ReadElementString() ); Console::WriteLine( "Content of the price element: {0}", reader->ReadElementString() ); } finally { if ( reader != nullptr ) reader->Close(); } }
import System.*; import System.Xml.*; public class Sample { private static String fileName = "book.xml"; public static void main(String[] args) { XmlTextReader reader = null; try { // Load the file and ignore all white space. reader = new XmlTextReader(fileName); reader.set_WhitespaceHandling(WhitespaceHandling.None); // Moves the reader to the root element. reader.MoveToContent(); // Read the title and price elements. Console.WriteLine("Content of the title element: {0}", reader.ReadElementString()); Console.WriteLine("Content of the price element: {0}", reader.ReadElementString()); } finally { if (reader != null) { reader.Close(); } } } // main } // End class Sample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


XmlReader.ReadElementString メソッド (String, String)
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlReader Dim localname As String Dim ns As String Dim returnValue As String returnValue = instance.ReadElementString(localname, ns)
戻り値
読み取られた要素内に格納されているテキスト。要素が空 (<item></item> または <item/>) の場合は、空の文字列。


これは、単純なテキストだけの要素を読み取るためのヘルパー メソッドです。MoveToContent を呼び出して、次のコンテンツ ノードを検索してから、その値を単純文字列として解析します。
XML、<name>Arlene Huff</name>、ReadElementString を使用すると、要素が処理され、文字列 Arlene Huff が返されます。
このメソッドは name 要素内のマークアップ (子要素、コメント、処理命令など) を処理できませんが、複数の隣接したテキスト ブロックと CDATA ブロックを連結できます。

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


XmlReader.ReadElementString メソッド (String)
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlReader Dim name As String Dim returnValue As String returnValue = instance.ReadElementString(name)
戻り値
読み取られた要素内に格納されているテキスト。要素が空 (<item></item> または <item/>) の場合は、空の文字列。


これは、単純なテキストだけの要素を読み取るためのヘルパー メソッドです。MoveToContent を呼び出して、次のコンテンツ ノードを検索してから、その値を単純文字列として解析します。
XML、<name>Arlene Huff</name>、ReadElementString を使用すると、要素が処理され、文字列 Arlene Huff が返されます。
このメソッドは name 要素内のマークアップ (子要素、コメント、処理命令など) を処理できませんが、複数の隣接したテキスト ブロックと CDATA ブロックを連結できます。

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


XmlReader.ReadElementString メソッド

名前 | 説明 |
---|---|
XmlReader.ReadElementString () | テキストだけの要素を読み取ります。 .NET Compact Framework によってサポートされています。 |
XmlReader.ReadElementString (String) | テキストだけの要素を読み取る前に、見つかった要素の Name プロパティが、指定した文字列と一致することを確認します。 .NET Compact Framework によってサポートされています。 |
XmlReader.ReadElementString (String, String) | テキストだけの要素を読み取る前に、見つかった要素の LocalName プロパティと NamespaceURI プロパティが、指定した文字列と一致することを確認します。 .NET Compact Framework によってサポートされています。 |
