LINQ-to-XML Error "is not a member of 'String'"
Posted
by mmcglynn
on Stack Overflow
See other posts from Stack Overflow
or by mmcglynn
Published on 2010-03-24T15:01:45Z
Indexed on
2010/03/24
15:03 UTC
Read the original article
Hit count: 238
linq-to-xml
The following code returns the error from the For Each loop. I have similar code that does not return the error.
'DisplayTitle' is not a member of 'Sting'
Dim evXML As XDocument = XDocument.Load(Server.MapPath("~/App_Data/event.xml"))
Dim sbEventDetail As New StringBuilder()
Dim summary = _
From sum In evXML.<root>.Elements() _
Select sum...<DisplayTitle>.Value
For Each item In summary
sbEventDetail.Append("<h4>" & item.DisplayTitle & "</h4>")
Next
The XML:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<StartTime>2010-03-05T16:00:00</StartTime>
<EndTime>2010-03-06T02:00:00</EndTime>
<Duration>10:00:00</Duration>
<DisplayTitle>MARCH MADNESS</DisplayTitle>
<Location>565 Main St</Location>
<IsAllDay>False</IsAllDay>
<Recurrence>
<OriginatingTimeZone>Eastern Standard Time</OriginatingTimeZone>
<RecurrenceType>0</RecurrenceType>
<RecurrenceEndDate>9999-12-31T23:59:59</RecurrenceEndDate>
</Recurrence>
<IsVariance>False</IsVariance>
<IsCancelled>False</IsCancelled>
<OriginalStart>0001-01-01T00:00:00</OriginalStart>
</root>
© Stack Overflow or respective owner