我当前正在解析以下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
要让XElement对象读取多行值,是否需要执行某些操作,或者我是否遗漏了其他操作?