現在、値を読み取って Web ページに表示するために解析している次の XML フラグメントがあります。
<root>
<PostcardTitle>The Needles</PostcardTitle>
<PostcardDescr>Granite Dells, Prescott</PostcardDescr>
<PostcardImage>
<img alt="GraniteDells" src="GraniteDells.jpg" />
</PostcardImage>
<PostcardDate />
<PostcardCredit>Photo Courtesy of Joe Schmoe</PostcardCredit>
</root>
私は次のコードを使用してこれを行っています(データベースからフラグメントを読み取ります):
Dim ContentDoc As XDocument
Dim DocPoints As IEnumerable(Of XElement)
ContentDoc = XDocument.Parse(ContentData.Item(0).content)
DocPoints = ContentDoc.<root>.Elements()
For Each Item As XElement In DocPoints
Dim TempLabel As New Label
TempLabel.Text = Item.Name.LocalName & ": " & Item.Value
Dim TempLiteral As New Literal
TempLiteral.Text = "<br/><br/>"
pnlEditItems.Controls.Add(TempLabel)
pnlEditItems.Controls.Add(TempLiteral)
Next
スクリプトを実行すると、PostcardImage ノードを除くすべてのノードが正常に解析され、空の PostcardDate ノードを含めて表示されます。デバッグ時に Item.Value を評価すると、空の文字列が返されます。ただし、Item.ToString() を評価すると、PostcardItem タグとその中の値が返されます。
XElement オブジェクトに複数行の値を読み取らせるために必要なことはありますか、それとも他に何か不足していますか?