473,732 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading XML into collection slow

I have an ASP group calendar application which pulls calendar data from
Exchange via webdav into an XML string. I then loop the XML nodes to
populate a collection of appointments. Finally I use the appointment
collection to populate the calendar control. The performance getting the
XML data is fine, but loading the data into the collection is slow. My
question/problem is should I be using the collection, a dataset, or
something else to load the xml data into the calendar control?
Thanks,
Kurt Bauer
Nov 11 '05 #1
5 2729
Kurt,

How are you loading the Xml data into the collection? If you could post code
or proovide some details I could probably provide some details. There may be
faster ways to do it. Does populating the collection involve executing a lot
of XPath expressions? Then make sure you are using an XPathDocument. Is it
simple, forward-only parsing of the XML, then you should try using an
XmlReader or XmlSerializatio n (which is built around XmlReaders).

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML .NET

"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
I have an ASP group calendar application which pulls calendar data from
Exchange via webdav into an XML string. I then loop the XML nodes to
populate a collection of appointments. Finally I use the appointment
collection to populate the calendar control. The performance getting the
XML data is fine, but loading the data into the collection is slow. My
question/problem is should I be using the collection, a dataset, or
something else to load the xml data into the calendar control?
Thanks,
Kurt Bauer

Nov 11 '05 #2
Thanks for the help. Using the reader has helped a little bit in the
performance, but I am still taking a big hit when I load the data into my
collection. If I write the output directly to the console it takes a split
second to write 24 appointments. As soon as I load the XML into the
collection and then loop through the collection to display an appointment,
the time jumps up to over 5 seconds.
The main reason I load the data into the collection is so I can loop through
the collection in the dayrender of the calendar control. Is there a better
way to get from the XML string to populating the calendar control that I am
missing?
Thanks,
Kurt Bauer

Here is my new code using the XML reader:
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
If it.Count > 0 Then
oAppointments = New Calendar.Appoin tments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appoin tment
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
oAppointment.Ca tegory = Mid(children.Cu rrent.Value, 1,
intIndex - 1)
oAppointment.Su bject = Mid(children.Cu rrent.Value,
intIndex + 1)
Else
oAppointment.Su bject = children.Curren t.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.St artTime = children.Curren t.Value
Case "dtend"
oAppointment.En dTime = children.Curren t.Value
Case "location"
oAppointment.Lo cation = children.Curren t.Value
Case "alldayeven t"
oAppointment.Al lDayEvent = children.Curren t.Value
Case "reminderoffset "
oAppointment.Re minderOffset = children.Curren t.Value / 60
Case "descriptio n"
oAppointment.Bo dy = children.Curren t.Value
End Select
End While
oAppointments.A dd(oAppointment )
oAppointment = Nothing
End While
End If

Here are my 2 collections for reference:
Public Class Appointments
Implements IEnumerable
Private mcolItems As Collection

Public Sub New()
mcolItems = New Collection
End Sub

Public ReadOnly Property Count()
Get
Count = mcolItems.Count
End Get
End Property

Sub Add(ByVal objNew As Calendar.Appoin tment)
mcolItems.Add(o bjNew)
End Sub

Public ReadOnly Property Item(ByVal vIndex As Object) As Appointment
Get
Item = mcolItems.Item( vIndex)
End Get
End Property
End Class

Public Class Appointment
Private strUrl As String
Private dtStartTime As DateTime
Private dtEndTime As DateTime
Private strSubject As String
Private strLocation As String
Private strBody As String
Private strCategory As String
Private strBusyStatus As String
Private blnAllDayEvent As Boolean
Private lngReminderOffs et As Long
Private objAttendies As Calendar.Attend ies

Public Property EmailUrl() As String
Get
Return strUrl
End Get
Set(ByVal Value As String)
strUrl = Value
End Set
End Property

Public Property StartTime() As DateTime
Get
Return dtStartTime
End Get
Set(ByVal Value As DateTime)
dtStartTime = Value
End Set
End Property

Public Property EndTime() As DateTime
Get
Return dtEndTime
End Get
Set(ByVal Value As DateTime)
dtEndTime = Value
End Set
End Property

Public Property Subject() As String
Get
Return strSubject
End Get
Set(ByVal Value As String)
strSubject = Value
End Set
End Property

Public Property Location() As String
Get
Return strLocation
End Get
Set(ByVal Value As String)
strLocation = Value
End Set
End Property

Public Property Body() As String
Get
Return strBody
End Get
Set(ByVal Value As String)
strBody = Value
End Set
End Property

Public Property Category() As String
Get
Return strCategory
End Get
Set(ByVal Value As String)
strCategory = Value
End Set
End Property

Public Property BusyStatus() As String
Get
Return strBusyStatus
End Get
Set(ByVal Value As String)
strBusyStatus = Value
End Set
End Property

Public Property AllDayEvent() As Boolean
Get
Return blnAllDayEvent
End Get
Set(ByVal Value As Boolean)
blnAllDayEvent = Value
End Set
End Property

Public Property ReminderOffset( ) As Long
Get
Return lngReminderOffs et
End Get
Set(ByVal Value As Long)
lngReminderOffs et = Value
End Set
End Property

Public Property Attendies() As Calendar.Attend ies
Get
Return objAttendies
End Get
Set(ByVal Value As Calendar.Attend ies)
objAttendies = Value
End Set
End Property

Sub New()
objAttendies = Calendar.Attend ies.GetAttendie s
End Sub
End Class
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:ue******** ******@TK2MSFTN GP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterat or combo rather than the XmlDocument. This combo is optimized for read-only XPath access and performs better than the SelectNodes couterpart.

See the code snippet below. I hope you get the idea:

Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
Console.WriteLi ne(String.Forma t("Category {0}",
Mid(children.Cu rrent.Value, 1, intIndex - 1)))
Console.WriteLi ne(String.Forma t("subject {0}",
Mid(children.Cu rrent.Value, intIndex + 1)))
Else
children.Curren t.MoveToFirstCh ild()
Console.WriteLi ne(String.Forma t("subject {0}",
children.Curren t.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:uK******** ******@TK2MSFTN GP09.phx.gbl...
I'm pretty new to .net development, so I used an msdn article to give me
some guidance on getting the xml from Exchange. Here is a link.

http://msdn.microsoft.com/library/de...asp?frame=true
Here is my function to parse my xml string.

Private Shared Function ConvertXMLtoApp ointment(ByVal strXML As
String) As Calendar.Appoin tments
' this routine takes the XML stream and puts it into a
collection of appointments
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim oXML As New Xml.XmlDocument
oXML.LoadXml(st rXML)

Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(oXML.NameT able)
oNSManager.AddN amespace("a", "DAV:")

Dim oResponses As Xml.XmlNodeList =

oXML.SelectNode s("//a:prop",
oNSManager)
oXML = Nothing
oNSManager = Nothing

Dim iResponseLoop As Int16
Dim iLoop As Int16
' Walk the response collection
If oResponses.Coun t > 0 Then
Try
'load collection
oAppointments = New Calendar.Appoin tments

'loop through each response
For iResponseLoop = 0 To oResponses.Coun t - 1
'load appointment into collection
Dim oNode As Xml.XmlNode
oNode = oResponses.Item (iResponseLoop)
oAppointment = New Calendar.Appoin tment

For iLoop = 0 To oNode.ChildNode s.Count - 1
Select Case oNode.ChildNode s.Item(iLoop).N ame
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1,
oNode.ChildNode s.Item(iLoop).I nnerText, ":")

If intIndex > 0 Then
oAppointment.Ca tegory =
Mid(oNode.Child Nodes.Item(iLoo p).InnerText, 1, intIndex - 1)
oAppointment.Su bject =
Mid(oNode.Child Nodes.Item(iLoo p).InnerText, intIndex + 1)
Else
oAppointment.Su bject =
oNode.ChildNode s.Item(iLoop).I nnerText
End If
intIndex = Nothing

Select Case oAppointment.Ca tegory
Case "Conference Call"
Case "Events"
Case "Meeting"
Case "Other"
Case "Personal"
Case "Vacation"
Case Else
oAppointment.Ca tegory = ""
oAppointment.Su bject =
oNode.ChildNode s.Item(iLoop).I nnerText
End Select
Case "dtstart"
oAppointment.St artTime =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "dtend"
oAppointment.En dTime =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "location"
oAppointment.Lo cation =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "alldayeven t"
oAppointment.Al lDayEvent =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "reminderoffset "
oAppointment.Re minderOffset =
oNode.ChildNode s.Item(iLoop).I nnerText / 60
Case "descriptio n"
oAppointment.Bo dy =
oNode.ChildNode s.Item(iLoop).I nnerText
End Select
Next
oAppointments.A dd(oAppointment )
oAppointment = Nothing
Next
Catch ex As Exception
oAppointment = Nothing
Finally
iLoop = Nothing
iResponseLoop = Nothing
End Try
End If
oResponses = Nothing
ConvertXMLtoApp ointment = oAppointments
oAppointments = Nothing
oAppointment = Nothing
End Function
Here is a small sample of an xml string I am trying to parse into my
collection.

<?xml version="1.0"?> <a:multistatu s
xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:"
xmlns:d="urn:sc hemas-microsoft-com:office:offi ce"

xmlns:a="DAV:"> <a:response><a: href>http://localhost/exchange/kurtbauer/Calen

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.E ML</a:href><a:props tat><a:status
HTTP/1.1 200

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{D1A4
4985-AD7A-41E9-97BA-A6245517AB4C}.E ML</url><subject>Co nference Call:Add my
initials KB</subject><dtstar t
b:dt="dateTime. tz">2003-07-15T21:00:00.000 Z</dtstart><dtend

b:dt="dateTime. tz">2003-07-15T22:00:00.000 Z</dtend></a:prop></a:propstat></a

:response><a:re sponse><a:href> http://localhost/exchange/kurtbauer/Calendar/{

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</a:href><a:props tat><a:status>H TTP
/1.1 200

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{FF5A
919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</url><subject>Va cation:I need a
vacation (KB)</subject><dtstar t
b:dt="dateTime. tz">2003-07-27T04:00:00.000 Z</dtstart><dtend

b:dt="dateTime. tz">2003-07-28T04:00:00.000 Z</dtend></a:prop></a:propstat></a
:response></a:multistatus>

Thanks,
Kurt Bauer
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in message news:O6******** ******@tk2msftn gp13.phx.gbl...
Kurt,

How are you loading the Xml data into the collection? If you could post
code
or proovide some details I could probably provide some details. There may
be
faster ways to do it. Does populating the collection involve executing

a lot
of XPath expressions? Then make sure you are using an XPathDocument.
Is it simple, forward-only parsing of the XML, then you should try using an
XmlReader or XmlSerializatio n (which is built around XmlReaders).

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML .NET

"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
> I have an ASP group calendar application which pulls calendar data from > Exchange via webdav into an XML string. I then loop the XML nodes
to > populate a collection of appointments. Finally I use the appointment > collection to populate the calendar control. The performance

getting the
> XML data is fine, but loading the data into the collection is slow.

My > question/problem is should I be using the collection, a dataset, or
> something else to load the xml data into the calendar control?
> Thanks,
> Kurt Bauer
>
>



Nov 11 '05 #3
It sounds more like that there is something going on inside the Appointments
collection when you populate the data.

Do you have a profiler available to see where the bottleneck is and if it's
really the XML parsing that's at fault here?
Have you tried to populate your appointments from a simple string array how
much faster is that compared to populating it from the Xml doc?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:ue******** ******@TK2MSFTN GP12.phx.gbl...
Thanks for the help. Using the reader has helped a little bit in the
performance, but I am still taking a big hit when I load the data into my
collection. If I write the output directly to the console it takes a split second to write 24 appointments. As soon as I load the XML into the
collection and then loop through the collection to display an appointment,
the time jumps up to over 5 seconds.
The main reason I load the data into the collection is so I can loop through the collection in the dayrender of the calendar control. Is there a better way to get from the XML string to populating the calendar control that I am missing?
Thanks,
Kurt Bauer

Here is my new code using the XML reader:
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
If it.Count > 0 Then
oAppointments = New Calendar.Appoin tments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appoin tment
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
oAppointment.Ca tegory = Mid(children.Cu rrent.Value, 1,
intIndex - 1)
oAppointment.Su bject = Mid(children.Cu rrent.Value,
intIndex + 1)
Else
oAppointment.Su bject = children.Curren t.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.St artTime = children.Curren t.Value
Case "dtend"
oAppointment.En dTime = children.Curren t.Value
Case "location"
oAppointment.Lo cation = children.Curren t.Value
Case "alldayeven t"
oAppointment.Al lDayEvent = children.Curren t.Value
Case "reminderoffset "
oAppointment.Re minderOffset = children.Curren t.Value / 60
Case "descriptio n"
oAppointment.Bo dy = children.Curren t.Value
End Select
End While
oAppointments.A dd(oAppointment )
oAppointment = Nothing
End While
End If

Here are my 2 collections for reference:
Public Class Appointments
Implements IEnumerable
Private mcolItems As Collection

Public Sub New()
mcolItems = New Collection
End Sub

Public ReadOnly Property Count()
Get
Count = mcolItems.Count
End Get
End Property

Sub Add(ByVal objNew As Calendar.Appoin tment)
mcolItems.Add(o bjNew)
End Sub

Public ReadOnly Property Item(ByVal vIndex As Object) As Appointment
Get
Item = mcolItems.Item( vIndex)
End Get
End Property
End Class

Public Class Appointment
Private strUrl As String
Private dtStartTime As DateTime
Private dtEndTime As DateTime
Private strSubject As String
Private strLocation As String
Private strBody As String
Private strCategory As String
Private strBusyStatus As String
Private blnAllDayEvent As Boolean
Private lngReminderOffs et As Long
Private objAttendies As Calendar.Attend ies

Public Property EmailUrl() As String
Get
Return strUrl
End Get
Set(ByVal Value As String)
strUrl = Value
End Set
End Property

Public Property StartTime() As DateTime
Get
Return dtStartTime
End Get
Set(ByVal Value As DateTime)
dtStartTime = Value
End Set
End Property

Public Property EndTime() As DateTime
Get
Return dtEndTime
End Get
Set(ByVal Value As DateTime)
dtEndTime = Value
End Set
End Property

Public Property Subject() As String
Get
Return strSubject
End Get
Set(ByVal Value As String)
strSubject = Value
End Set
End Property

Public Property Location() As String
Get
Return strLocation
End Get
Set(ByVal Value As String)
strLocation = Value
End Set
End Property

Public Property Body() As String
Get
Return strBody
End Get
Set(ByVal Value As String)
strBody = Value
End Set
End Property

Public Property Category() As String
Get
Return strCategory
End Get
Set(ByVal Value As String)
strCategory = Value
End Set
End Property

Public Property BusyStatus() As String
Get
Return strBusyStatus
End Get
Set(ByVal Value As String)
strBusyStatus = Value
End Set
End Property

Public Property AllDayEvent() As Boolean
Get
Return blnAllDayEvent
End Get
Set(ByVal Value As Boolean)
blnAllDayEvent = Value
End Set
End Property

Public Property ReminderOffset( ) As Long
Get
Return lngReminderOffs et
End Get
Set(ByVal Value As Long)
lngReminderOffs et = Value
End Set
End Property

Public Property Attendies() As Calendar.Attend ies
Get
Return objAttendies
End Get
Set(ByVal Value As Calendar.Attend ies)
objAttendies = Value
End Set
End Property

Sub New()
objAttendies = Calendar.Attend ies.GetAttendie s
End Sub
End Class
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:ue******** ******@TK2MSFTN GP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterat or combo rather than the XmlDocument.
This combo is optimized for read-only XPath access and performs better

than
the SelectNodes couterpart.

See the code snippet below. I hope you get the idea:

Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
Console.WriteLi ne(String.Forma t("Category {0}",
Mid(children.Cu rrent.Value, 1, intIndex - 1)))
Console.WriteLi ne(String.Forma t("subject {0}",
Mid(children.Cu rrent.Value, intIndex + 1)))
Else
children.Curren t.MoveToFirstCh ild()
Console.WriteLi ne(String.Forma t("subject {0}",
children.Curren t.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:uK******** ******@TK2MSFTN GP09.phx.gbl...
I'm pretty new to .net development, so I used an msdn article to give me some guidance on getting the xml from Exchange. Here is a link.

http://msdn.microsoft.com/library/de...asp?frame=true
Here is my function to parse my xml string.

Private Shared Function ConvertXMLtoApp ointment(ByVal strXML As String) As Calendar.Appoin tments
' this routine takes the XML stream and puts it into a
collection of appointments
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim oXML As New Xml.XmlDocument
oXML.LoadXml(st rXML)

Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(oXML.NameT able)
oNSManager.AddN amespace("a", "DAV:")

Dim oResponses As Xml.XmlNodeList =

oXML.SelectNode s("//a:prop",
oNSManager)
oXML = Nothing
oNSManager = Nothing

Dim iResponseLoop As Int16
Dim iLoop As Int16
' Walk the response collection
If oResponses.Coun t > 0 Then
Try
'load collection
oAppointments = New Calendar.Appoin tments

'loop through each response
For iResponseLoop = 0 To oResponses.Coun t - 1
'load appointment into collection
Dim oNode As Xml.XmlNode
oNode = oResponses.Item (iResponseLoop)
oAppointment = New Calendar.Appoin tment

For iLoop = 0 To oNode.ChildNode s.Count - 1
Select Case oNode.ChildNode s.Item(iLoop).N ame Case "subject"
Dim intIndex As Integer
intIndex = InStr(1,
oNode.ChildNode s.Item(iLoop).I nnerText, ":")

If intIndex > 0 Then
oAppointment.Ca tegory =
Mid(oNode.Child Nodes.Item(iLoo p).InnerText, 1, intIndex - 1)
oAppointment.Su bject =
Mid(oNode.Child Nodes.Item(iLoo p).InnerText, intIndex + 1)
Else
oAppointment.Su bject =
oNode.ChildNode s.Item(iLoop).I nnerText
End If
intIndex = Nothing

Select Case oAppointment.Ca tegory
Case "Conference Call"
Case "Events"
Case "Meeting"
Case "Other"
Case "Personal"
Case "Vacation"
Case Else
oAppointment.Ca tegory = ""
oAppointment.Su bject =
oNode.ChildNode s.Item(iLoop).I nnerText
End Select
Case "dtstart"
oAppointment.St artTime =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "dtend"
oAppointment.En dTime =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "location"
oAppointment.Lo cation =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "alldayeven t"
oAppointment.Al lDayEvent =
oNode.ChildNode s.Item(iLoop).I nnerText
Case "reminderoffset "
oAppointment.Re minderOffset =
oNode.ChildNode s.Item(iLoop).I nnerText / 60
Case "descriptio n"
oAppointment.Bo dy =
oNode.ChildNode s.Item(iLoop).I nnerText
End Select
Next
oAppointments.A dd(oAppointment )
oAppointment = Nothing
Next
Catch ex As Exception
oAppointment = Nothing
Finally
iLoop = Nothing
iResponseLoop = Nothing
End Try
End If
oResponses = Nothing
ConvertXMLtoApp ointment = oAppointments
oAppointments = Nothing
oAppointment = Nothing
End Function
Here is a small sample of an xml string I am trying to parse into my
collection.

<?xml version="1.0"?> <a:multistatu s
xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" xmlns:d="urn:sc hemas-microsoft-com:office:offi ce"

xmlns:a="DAV:"> <a:response><a: href>http://localhost/exchange/kurtbauer/Calen

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.E ML</a:href><a:props tat><a:status
>HTTP/1.1 200

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{D1A4
4985-AD7A-41E9-97BA-A6245517AB4C}.E ML</url><subject>Co nference Call:Add my
initials KB</subject><dtstar t
b:dt="dateTime. tz">2003-07-15T21:00:00.000 Z</dtstart><dtend

b:dt="dateTime. tz">2003-07-15T22:00:00.000 Z</dtend></a:prop></a:propstat></a

:response><a:re sponse><a:href> http://localhost/exchange/kurtbauer/Calendar/{

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</a:href><a:props tat><a:status>H TTP
/1.1 200

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{FF5A
919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</url><subject>Va cation:I need a
vacation (KB)</subject><dtstar t
b:dt="dateTime. tz">2003-07-27T04:00:00.000 Z</dtstart><dtend

b:dt="dateTime. tz">2003-07-28T04:00:00.000 Z</dtend></a:prop></a:propstat></a
:response></a:multistatus>

Thanks,
Kurt Bauer
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:O6******** ******@tk2msftn gp13.phx.gbl...
> Kurt,
>
> How are you loading the Xml data into the collection? If you could post code
> or proovide some details I could probably provide some details.
There
may
be
> faster ways to do it. Does populating the collection involve
executing
a lot
> of XPath expressions? Then make sure you are using an XPathDocument. Is
it
> simple, forward-only parsing of the XML, then you should try using

an > XmlReader or XmlSerializatio n (which is built around XmlReaders).
>
> HTH,
> Christoph Schittko
> Software Architect, .NET Mentor
> MVP XML .NET
>
> "Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
> news:e8******** ******@TK2MSFTN GP12.phx.gbl...
> > I have an ASP group calendar application which pulls calendar data

from
> > Exchange via webdav into an XML string. I then loop the XML nodes

to > > populate a collection of appointments. Finally I use the appointment > > collection to populate the calendar control. The performance getting the
> > XML data is fine, but loading the data into the collection is slow. My
> > question/problem is should I be using the collection, a dataset,

or > > something else to load the xml data into the calendar control?
> > Thanks,
> > Kurt Bauer
> >
> >
>
>



Nov 11 '05 #4
I'm getting closer. The slow down occurs when I instantiate a new
oAppointment object.
After I loop through each child in the appointment, I add the appointment
object to my appointments collection. Then I set the appointment object to
nothing, but I then create a new appointment object for the next appointment
in the xml string.
I tried not destroying and recreating the appointment object after each loop
to the string, but when I then loop through my collection of appointments
after processing my xml string, I have the correct number of appointments in
the collection, but they are all just copies of the last appointment added
to the collection.
So is there an easy to populate the collection of appointments without
destroying and recreating my appointment object on each loop?
Thanks,
Kurt

"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:%2******** **********@TK2M SFTNGP12.phx.gb l...
It sounds more like that there is something going on inside the Appointments collection when you populate the data.

Do you have a profiler available to see where the bottleneck is and if it's really the XML parsing that's at fault here?
Have you tried to populate your appointments from a simple string array how much faster is that compared to populating it from the Xml doc?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:ue******** ******@TK2MSFTN GP12.phx.gbl...
Thanks for the help. Using the reader has helped a little bit in the
performance, but I am still taking a big hit when I load the data into my
collection. If I write the output directly to the console it takes a split
second to write 24 appointments. As soon as I load the XML into the
collection and then loop through the collection to display an appointment, the time jumps up to over 5 seconds.
The main reason I load the data into the collection is so I can loop

through
the collection in the dayrender of the calendar control. Is there a

better
way to get from the XML string to populating the calendar control that I

am
missing?
Thanks,
Kurt Bauer

Here is my new code using the XML reader:
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
If it.Count > 0 Then
oAppointments = New Calendar.Appoin tments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appoin tment
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
oAppointment.Ca tegory = Mid(children.Cu rrent.Value, 1, intIndex - 1)
oAppointment.Su bject = Mid(children.Cu rrent.Value,
intIndex + 1)
Else
oAppointment.Su bject = children.Curren t.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.St artTime = children.Curren t.Value
Case "dtend"
oAppointment.En dTime = children.Curren t.Value
Case "location"
oAppointment.Lo cation = children.Curren t.Value
Case "alldayeven t"
oAppointment.Al lDayEvent = children.Curren t.Value
Case "reminderoffset "
oAppointment.Re minderOffset = children.Curren t.Value / 60 Case "descriptio n"
oAppointment.Bo dy = children.Curren t.Value
End Select
End While
oAppointments.A dd(oAppointment )
oAppointment = Nothing
End While
End If

Here are my 2 collections for reference:
Public Class Appointments
Implements IEnumerable
Private mcolItems As Collection

Public Sub New()
mcolItems = New Collection
End Sub

Public ReadOnly Property Count()
Get
Count = mcolItems.Count
End Get
End Property

Sub Add(ByVal objNew As Calendar.Appoin tment)
mcolItems.Add(o bjNew)
End Sub

Public ReadOnly Property Item(ByVal vIndex As Object) As Appointment
Get
Item = mcolItems.Item( vIndex)
End Get
End Property
End Class

Public Class Appointment
Private strUrl As String
Private dtStartTime As DateTime
Private dtEndTime As DateTime
Private strSubject As String
Private strLocation As String
Private strBody As String
Private strCategory As String
Private strBusyStatus As String
Private blnAllDayEvent As Boolean
Private lngReminderOffs et As Long
Private objAttendies As Calendar.Attend ies

Public Property EmailUrl() As String
Get
Return strUrl
End Get
Set(ByVal Value As String)
strUrl = Value
End Set
End Property

Public Property StartTime() As DateTime
Get
Return dtStartTime
End Get
Set(ByVal Value As DateTime)
dtStartTime = Value
End Set
End Property

Public Property EndTime() As DateTime
Get
Return dtEndTime
End Get
Set(ByVal Value As DateTime)
dtEndTime = Value
End Set
End Property

Public Property Subject() As String
Get
Return strSubject
End Get
Set(ByVal Value As String)
strSubject = Value
End Set
End Property

Public Property Location() As String
Get
Return strLocation
End Get
Set(ByVal Value As String)
strLocation = Value
End Set
End Property

Public Property Body() As String
Get
Return strBody
End Get
Set(ByVal Value As String)
strBody = Value
End Set
End Property

Public Property Category() As String
Get
Return strCategory
End Get
Set(ByVal Value As String)
strCategory = Value
End Set
End Property

Public Property BusyStatus() As String
Get
Return strBusyStatus
End Get
Set(ByVal Value As String)
strBusyStatus = Value
End Set
End Property

Public Property AllDayEvent() As Boolean
Get
Return blnAllDayEvent
End Get
Set(ByVal Value As Boolean)
blnAllDayEvent = Value
End Set
End Property

Public Property ReminderOffset( ) As Long
Get
Return lngReminderOffs et
End Get
Set(ByVal Value As Long)
lngReminderOffs et = Value
End Set
End Property

Public Property Attendies() As Calendar.Attend ies
Get
Return objAttendies
End Get
Set(ByVal Value As Calendar.Attend ies)
objAttendies = Value
End Set
End Property

Sub New()
objAttendies = Calendar.Attend ies.GetAttendie s
End Sub
End Class
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in message news:ue******** ******@TK2MSFTN GP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterat or combo rather than the

XmlDocument.
This combo is optimized for read-only XPath access and performs better

than
the SelectNodes couterpart.

See the code snippet below. I hope you get the idea:

Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
Console.WriteLi ne(String.Forma t("Category {0}",
Mid(children.Cu rrent.Value, 1, intIndex - 1)))
Console.WriteLi ne(String.Forma t("subject {0}",
Mid(children.Cu rrent.Value, intIndex + 1)))
Else
children.Curren t.MoveToFirstCh ild()
Console.WriteLi ne(String.Forma t("subject {0}",
children.Curren t.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:uK******** ******@TK2MSFTN GP09.phx.gbl...
> I'm pretty new to .net development, so I used an msdn article to give me > some guidance on getting the xml from Exchange. Here is a link.
>

http://msdn.microsoft.com/library/de...asp?frame=true > Here is my function to parse my xml string.
>
> Private Shared Function ConvertXMLtoApp ointment(ByVal strXML As > String) As Calendar.Appoin tments
> ' this routine takes the XML stream and puts it into a
> collection of appointments
> Dim oAppointment As Calendar.Appoin tment
> Dim oAppointments As Calendar.Appoin tments
> Dim oXML As New Xml.XmlDocument
> oXML.LoadXml(st rXML)
>
> Dim oNSManager As XmlNamespaceMan ager = New
> XmlNamespaceMan ager(oXML.NameT able)
> oNSManager.AddN amespace("a", "DAV:")
>
> Dim oResponses As Xml.XmlNodeList =
oXML.SelectNode s("//a:prop",
> oNSManager)
> oXML = Nothing
> oNSManager = Nothing
>
> Dim iResponseLoop As Int16
> Dim iLoop As Int16
> ' Walk the response collection
> If oResponses.Coun t > 0 Then
> Try
> 'load collection
> oAppointments = New Calendar.Appoin tments
>
> 'loop through each response
> For iResponseLoop = 0 To oResponses.Coun t - 1
> 'load appointment into collection
> Dim oNode As Xml.XmlNode
> oNode = oResponses.Item (iResponseLoop)
> oAppointment = New Calendar.Appoin tment
>
> For iLoop = 0 To oNode.ChildNode s.Count - 1
> Select Case

oNode.ChildNode s.Item(iLoop).N ame
> Case "subject"
> Dim intIndex As Integer
> intIndex = InStr(1,
> oNode.ChildNode s.Item(iLoop).I nnerText, ":")
>
> If intIndex > 0 Then
> oAppointment.Ca tegory =
> Mid(oNode.Child Nodes.Item(iLoo p).InnerText, 1, intIndex - 1)
> oAppointment.Su bject =
> Mid(oNode.Child Nodes.Item(iLoo p).InnerText, intIndex + 1)
> Else
> oAppointment.Su bject =
> oNode.ChildNode s.Item(iLoop).I nnerText
> End If
> intIndex = Nothing
>
> Select Case oAppointment.Ca tegory > Case "Conference Call"
> Case "Events"
> Case "Meeting"
> Case "Other"
> Case "Personal"
> Case "Vacation"
> Case Else
> oAppointment.Ca tegory = "" > oAppointment.Su bject =
> oNode.ChildNode s.Item(iLoop).I nnerText
> End Select
> Case "dtstart"
> oAppointment.St artTime =
> oNode.ChildNode s.Item(iLoop).I nnerText
> Case "dtend"
> oAppointment.En dTime =
> oNode.ChildNode s.Item(iLoop).I nnerText
> Case "location"
> oAppointment.Lo cation =
> oNode.ChildNode s.Item(iLoop).I nnerText
> Case "alldayeven t"
> oAppointment.Al lDayEvent =
> oNode.ChildNode s.Item(iLoop).I nnerText
> Case "reminderoffset "
> oAppointment.Re minderOffset =
> oNode.ChildNode s.Item(iLoop).I nnerText / 60
> Case "descriptio n"
> oAppointment.Bo dy =
> oNode.ChildNode s.Item(iLoop).I nnerText
> End Select
> Next
> oAppointments.A dd(oAppointment )
> oAppointment = Nothing
> Next
> Catch ex As Exception
> oAppointment = Nothing
> Finally
> iLoop = Nothing
> iResponseLoop = Nothing
> End Try
> End If
> oResponses = Nothing
> ConvertXMLtoApp ointment = oAppointments
> oAppointments = Nothing
> oAppointment = Nothing
> End Function
>
>
> Here is a small sample of an xml string I am trying to parse into my
> collection.
>
> <?xml version="1.0"?> <a:multistatu s
> xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" > xmlns:d="urn:sc hemas-microsoft-com:office:offi ce"
>

xmlns:a="DAV:"> <a:response><a: href>http://localhost/exchange/kurtbauer/Calen
>

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.E ML</a:href><a:props tat><a:status
> >HTTP/1.1 200
>

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{D1A4
> 4985-AD7A-41E9-97BA-A6245517AB4C}.E ML</url><subject>Co nference Call:Add
my
> initials KB</subject><dtstar t
> b:dt="dateTime. tz">2003-07-15T21:00:00.000 Z</dtstart><dtend
>

b:dt="dateTime. tz">2003-07-15T22:00:00.000 Z</dtend></a:prop></a:propstat></a
>

:response><a:re sponse><a:href> http://localhost/exchange/kurtbauer/Calendar/{
>

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</a:href><a:props tat><a:status>H TTP
> /1.1 200
>

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{FF5A
> 919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</url><subject>Va cation:I need a > vacation (KB)</subject><dtstar t
> b:dt="dateTime. tz">2003-07-27T04:00:00.000 Z</dtstart><dtend
>

b:dt="dateTime. tz">2003-07-28T04:00:00.000 Z</dtend></a:prop></a:propstat></a
> :response></a:multistatus>
>
> Thanks,
> Kurt Bauer
>
>
> "Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote
in
> message news:O6******** ******@tk2msftn gp13.phx.gbl...
> > Kurt,
> >
> > How are you loading the Xml data into the collection? If you could

post
> code
> > or proovide some details I could probably provide some details. There may
> be
> > faster ways to do it. Does populating the collection involve executing
a
> lot
> > of XPath expressions? Then make sure you are using an XPathDocument. Is
it
> > simple, forward-only parsing of the XML, then you should try using an > > XmlReader or XmlSerializatio n (which is built around XmlReaders).
> >
> > HTH,
> > Christoph Schittko
> > Software Architect, .NET Mentor
> > MVP XML .NET
> >
> > "Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
> > news:e8******** ******@TK2MSFTN GP12.phx.gbl...
> > > I have an ASP group calendar application which pulls calendar
data from
> > > Exchange via webdav into an XML string. I then loop the XML

nodes to
> > > populate a collection of appointments. Finally I use the

appointment
> > > collection to populate the calendar control. The performance

getting
> the
> > > XML data is fine, but loading the data into the collection is

slow. My
> > > question/problem is should I be using the collection, a dataset, or > > > something else to load the xml data into the calendar control?
> > > Thanks,
> > > Kurt Bauer
> > >
> > >
> >
> >
>
>



Nov 11 '05 #5
Not that I am aware of. Maybe someone in the Exchange/Outlook (you're
talking about the Exchange or Outlook calendar, correct?) related groups can
provide some help here. You are probably dealing with out-of-process COM
servers and there's not good way to avoid the performance penalty unless
there is an API especially designed for that.

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:uo******** ******@tk2msftn gp13.phx.gbl...
I'm getting closer. The slow down occurs when I instantiate a new
oAppointment object.
After I loop through each child in the appointment, I add the appointment
object to my appointments collection. Then I set the appointment object to nothing, but I then create a new appointment object for the next appointment in the xml string.
I tried not destroying and recreating the appointment object after each loop to the string, but when I then loop through my collection of appointments
after processing my xml string, I have the correct number of appointments in the collection, but they are all just copies of the last appointment added
to the collection.
So is there an easy to populate the collection of appointments without
destroying and recreating my appointment object on each loop?
Thanks,
Kurt

"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:%2******** **********@TK2M SFTNGP12.phx.gb l...
It sounds more like that there is something going on inside the Appointments
collection when you populate the data.

Do you have a profiler available to see where the bottleneck is and if

it's
really the XML parsing that's at fault here?
Have you tried to populate your appointments from a simple string array

how
much faster is that compared to populating it from the Xml doc?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
news:ue******** ******@TK2MSFTN GP12.phx.gbl...
Thanks for the help. Using the reader has helped a little bit in the
performance, but I am still taking a big hit when I load the data into my collection. If I write the output directly to the console it takes a

split
second to write 24 appointments. As soon as I load the XML into the
collection and then loop through the collection to display an appointment, the time jumps up to over 5 seconds.
The main reason I load the data into the collection is so I can loop

through
the collection in the dayrender of the calendar control. Is there a

better
way to get from the XML string to populating the calendar control that I
am
missing?
Thanks,
Kurt Bauer

Here is my new code using the XML reader:
Dim oAppointment As Calendar.Appoin tment
Dim oAppointments As Calendar.Appoin tments
Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
Dim oNSManager As XmlNamespaceMan ager = New
XmlNamespaceMan ager(nav.NameTa ble)
Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop")
oNSManager.AddN amespace("a", "DAV:")
expression.SetC ontext(oNSManag er)
Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
If it.Count > 0 Then
oAppointments = New Calendar.Appoin tments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appoin tment
Dim appointments As Xml.XPath.XPath Navigator = it.Current
Dim children As Xml.XPath.XPath NodeIterator =
appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
While children.MoveNe xt
Select Case children.Curren t.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Curren t.Value, ":")
If intIndex > 0 Then
oAppointment.Ca tegory =
Mid(children.Cu rrent.Value, 1, intIndex - 1)
oAppointment.Su bject = Mid(children.Cu rrent.Value,
intIndex + 1)
Else
oAppointment.Su bject = children.Curren t.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.St artTime = children.Curren t.Value
Case "dtend"
oAppointment.En dTime = children.Curren t.Value
Case "location"
oAppointment.Lo cation = children.Curren t.Value
Case "alldayeven t"
oAppointment.Al lDayEvent = children.Curren t.Value
Case "reminderoffset "
oAppointment.Re minderOffset = children.Curren t.Value / 60 Case "descriptio n"
oAppointment.Bo dy = children.Curren t.Value
End Select
End While
oAppointments.A dd(oAppointment )
oAppointment = Nothing
End While
End If

Here are my 2 collections for reference:
Public Class Appointments
Implements IEnumerable
Private mcolItems As Collection

Public Sub New()
mcolItems = New Collection
End Sub

Public ReadOnly Property Count()
Get
Count = mcolItems.Count
End Get
End Property

Sub Add(ByVal objNew As Calendar.Appoin tment)
mcolItems.Add(o bjNew)
End Sub

Public ReadOnly Property Item(ByVal vIndex As Object) As
Appointment Get
Item = mcolItems.Item( vIndex)
End Get
End Property
End Class

Public Class Appointment
Private strUrl As String
Private dtStartTime As DateTime
Private dtEndTime As DateTime
Private strSubject As String
Private strLocation As String
Private strBody As String
Private strCategory As String
Private strBusyStatus As String
Private blnAllDayEvent As Boolean
Private lngReminderOffs et As Long
Private objAttendies As Calendar.Attend ies

Public Property EmailUrl() As String
Get
Return strUrl
End Get
Set(ByVal Value As String)
strUrl = Value
End Set
End Property

Public Property StartTime() As DateTime
Get
Return dtStartTime
End Get
Set(ByVal Value As DateTime)
dtStartTime = Value
End Set
End Property

Public Property EndTime() As DateTime
Get
Return dtEndTime
End Get
Set(ByVal Value As DateTime)
dtEndTime = Value
End Set
End Property

Public Property Subject() As String
Get
Return strSubject
End Get
Set(ByVal Value As String)
strSubject = Value
End Set
End Property

Public Property Location() As String
Get
Return strLocation
End Get
Set(ByVal Value As String)
strLocation = Value
End Set
End Property

Public Property Body() As String
Get
Return strBody
End Get
Set(ByVal Value As String)
strBody = Value
End Set
End Property

Public Property Category() As String
Get
Return strCategory
End Get
Set(ByVal Value As String)
strCategory = Value
End Set
End Property

Public Property BusyStatus() As String
Get
Return strBusyStatus
End Get
Set(ByVal Value As String)
strBusyStatus = Value
End Set
End Property

Public Property AllDayEvent() As Boolean
Get
Return blnAllDayEvent
End Get
Set(ByVal Value As Boolean)
blnAllDayEvent = Value
End Set
End Property

Public Property ReminderOffset( ) As Long
Get
Return lngReminderOffs et
End Get
Set(ByVal Value As Long)
lngReminderOffs et = Value
End Set
End Property

Public Property Attendies() As Calendar.Attend ies
Get
Return objAttendies
End Get
Set(ByVal Value As Calendar.Attend ies)
objAttendies = Value
End Set
End Property

Sub New()
objAttendies = Calendar.Attend ies.GetAttendie s
End Sub
End Class
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote
in message news:ue******** ******@TK2MSFTN GP10.phx.gbl...
> Kurt,
>
> try the XPathNavigator/XPathNodeIterat or combo rather than the
XmlDocument.
> This combo is optimized for read-only XPath access and performs
better than
> the SelectNodes couterpart.
>
> See the code snippet below. I hope you get the idea:
>
> Dim doc As Xml.XPath.XPath Document = New Xml.XPath.XPath Document(New
> XmlTextReader(N ew System.IO.Strin gReader(strXML) ))
> Dim nav As Xml.XPath.XPath Navigator = doc.CreateNavig ator()
> Dim oNSManager As XmlNamespaceMan ager = New
> XmlNamespaceMan ager(nav.NameTa ble)
> Dim expression As Xml.XPath.XPath Expression = nav.Compile("//a:prop") > oNSManager.AddN amespace("a", "DAV:")
> expression.SetC ontext(oNSManag er)
> Dim it As Xml.XPath.XPath NodeIterator = nav.Select(expr ession)
> ' Walk the response collection
> While it.MoveNext
> Dim appointments As Xml.XPath.XPath Navigator = it.Current
> Dim children As Xml.XPath.XPath NodeIterator =
> appointments.Se lectChildren(XP ath.XPathNodeTy pe.Element)
> While children.MoveNe xt
> Select Case children.Curren t.LocalName
> Case "subject"
> Dim intIndex As Integer
> intIndex = InStr(1, children.Curren t.Value, ":")
> If intIndex > 0 Then
> Console.WriteLi ne(String.Forma t("Category {0}",
> Mid(children.Cu rrent.Value, 1, intIndex - 1)))
> Console.WriteLi ne(String.Forma t("subject {0}",
> Mid(children.Cu rrent.Value, intIndex + 1)))
> Else
> children.Curren t.MoveToFirstCh ild()
> Console.WriteLi ne(String.Forma t("subject {0}",
> children.Curren t.Value))
> End If
> ' ...
>
> HTH,
> Christoph Schittko
> Software Architect, .NET Mentor
> MS MVP XML .NET
> "Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
> news:uK******** ******@TK2MSFTN GP09.phx.gbl...
> > I'm pretty new to .net development, so I used an msdn article to give
me
> > some guidance on getting the xml from Exchange. Here is a link.
> >
>

http://msdn.microsoft.com/library/de...asp?frame=true
> > Here is my function to parse my xml string.
> >
> > Private Shared Function ConvertXMLtoApp ointment(ByVal strXML As
> > String) As Calendar.Appoin tments
> > ' this routine takes the XML stream and puts it into a
> > collection of appointments
> > Dim oAppointment As Calendar.Appoin tment
> > Dim oAppointments As Calendar.Appoin tments
> > Dim oXML As New Xml.XmlDocument
> > oXML.LoadXml(st rXML)
> >
> > Dim oNSManager As XmlNamespaceMan ager = New
> > XmlNamespaceMan ager(oXML.NameT able)
> > oNSManager.AddN amespace("a", "DAV:")
> >
> > Dim oResponses As Xml.XmlNodeList =
> oXML.SelectNode s("//a:prop",
> > oNSManager)
> > oXML = Nothing
> > oNSManager = Nothing
> >
> > Dim iResponseLoop As Int16
> > Dim iLoop As Int16
> > ' Walk the response collection
> > If oResponses.Coun t > 0 Then
> > Try
> > 'load collection
> > oAppointments = New Calendar.Appoin tments
> >
> > 'loop through each response
> > For iResponseLoop = 0 To oResponses.Coun t - 1
> > 'load appointment into collection
> > Dim oNode As Xml.XmlNode
> > oNode = oResponses.Item (iResponseLoop)
> > oAppointment = New Calendar.Appoin tment
> >
> > For iLoop = 0 To oNode.ChildNode s.Count -
1 > > Select Case
oNode.ChildNode s.Item(iLoop).N ame
> > Case "subject"
> > Dim intIndex As Integer
> > intIndex = InStr(1,
> > oNode.ChildNode s.Item(iLoop).I nnerText, ":")
> >
> > If intIndex > 0 Then
> > oAppointment.Ca tegory =
> > Mid(oNode.Child Nodes.Item(iLoo p).InnerText, 1, intIndex - 1)
> > oAppointment.Su bject =
> > Mid(oNode.Child Nodes.Item(iLoo p).InnerText, intIndex + 1)
> > Else
> > oAppointment.Su bject =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > End If
> > intIndex = Nothing
> >
> > Select Case oAppointment.Ca tegory > > Case "Conference Call"
> > Case "Events"
> > Case "Meeting"
> > Case "Other"
> > Case "Personal"
> > Case "Vacation"
> > Case Else
> > oAppointment.Ca tegory = ""
> > oAppointment.Su bject =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > End Select
> > Case "dtstart"
> > oAppointment.St artTime =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > Case "dtend"
> > oAppointment.En dTime =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > Case "location"
> > oAppointment.Lo cation =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > Case "alldayeven t"
> > oAppointment.Al lDayEvent =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > Case "reminderoffset "
> > oAppointment.Re minderOffset =
> > oNode.ChildNode s.Item(iLoop).I nnerText / 60
> > Case "descriptio n"
> > oAppointment.Bo dy =
> > oNode.ChildNode s.Item(iLoop).I nnerText
> > End Select
> > Next
> > oAppointments.A dd(oAppointment )
> > oAppointment = Nothing
> > Next
> > Catch ex As Exception
> > oAppointment = Nothing
> > Finally
> > iLoop = Nothing
> > iResponseLoop = Nothing
> > End Try
> > End If
> > oResponses = Nothing
> > ConvertXMLtoApp ointment = oAppointments
> > oAppointments = Nothing
> > oAppointment = Nothing
> > End Function
> >
> >
> > Here is a small sample of an xml string I am trying to parse into
my > > collection.
> >
> > <?xml version="1.0"?> <a:multistatu s
> > xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:"
> > xmlns:d="urn:sc hemas-microsoft-com:office:offi ce"
> >
>

xmlns:a="DAV:"> <a:response><a: href>http://localhost/exchange/kurtbauer/Calen
> >
>

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.E ML</a:href><a:props tat><a:status
> > >HTTP/1.1 200
> >
>

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{D1A4
> > 4985-AD7A-41E9-97BA-A6245517AB4C}.E ML</url><subject>Co nference

Call:Add
my
> > initials KB</subject><dtstar t
> > b:dt="dateTime. tz">2003-07-15T21:00:00.000 Z</dtstart><dtend
> >
>

b:dt="dateTime. tz">2003-07-15T22:00:00.000 Z</dtend></a:prop></a:propstat></a
> >
>

:response><a:re sponse><a:href> http://localhost/exchange/kurtbauer/Calendar/{
> >
>

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</a:href><a:props tat><a:status>H TTP
> > /1.1 200
> >
>

OK</a:status><a:pro p><url>http://localhost/exchange/kurtbauer/Calendar/{FF5A
> > 919B-0FB0-4AF0-8013-42F4CC5F3B4D}.E ML</url><subject>Va cation:I need a
> > vacation (KB)</subject><dtstar t
> > b:dt="dateTime. tz">2003-07-27T04:00:00.000 Z</dtstart><dtend
> >
>

b:dt="dateTime. tz">2003-07-28T04:00:00.000 Z</dtend></a:prop></a:propstat></a > > :response></a:multistatus>
> >
> > Thanks,
> > Kurt Bauer
> >
> >
> > "Christoph Schittko [MVP]" <ch************ ********@austin .rr.com>

wrote
in
> > message news:O6******** ******@tk2msftn gp13.phx.gbl...
> > > Kurt,
> > >
> > > How are you loading the Xml data into the collection? If you could post
> > code
> > > or proovide some details I could probably provide some details.

There
> may
> > be
> > > faster ways to do it. Does populating the collection involve

executing
a
> > lot
> > > of XPath expressions? Then make sure you are using an XPathDocument. Is
> it
> > > simple, forward-only parsing of the XML, then you should try using an
> > > XmlReader or XmlSerializatio n (which is built around
XmlReaders). > > >
> > > HTH,
> > > Christoph Schittko
> > > Software Architect, .NET Mentor
> > > MVP XML .NET
> > >
> > > "Kurt Bauer" <kb****@NOSPAMt ampabay.rr.com> wrote in message
> > > news:e8******** ******@TK2MSFTN GP12.phx.gbl...
> > > > I have an ASP group calendar application which pulls calendar data > from
> > > > Exchange via webdav into an XML string. I then loop the XML nodes to
> > > > populate a collection of appointments. Finally I use the
appointment
> > > > collection to populate the calendar control. The performance
getting
> > the
> > > > XML data is fine, but loading the data into the collection is

slow.
> My
> > > > question/problem is should I be using the collection, a

dataset, or
> > > > something else to load the xml data into the calendar control?
> > > > Thanks,
> > > > Kurt Bauer
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2922
by: Philipp K. Janert, Ph.D. | last post by:
Dear All! I am trying to load a relatively large table (about 1 Million rows) into an sqlite table, which is kept in memory. The load process is very slow - on the order of 15 minutes or so. I am accessing sqlite from Python, using the pysqlite driver. I am loading all records first using cx.execute( "insert ..." ). Only once I have run cx.execute() for all records, I commit all
0
1676
by: smartin | last post by:
python IIS cgi loading extremely slow I recently uninstalled python 1.5.2 and installed python 2.3 on a Windows 2000 server running IIS 5.0. The issue is that when submitting a cgi request to a python script, it takes about 1 minute to process the python (2.3 code) and load the page on this particular server. Running a simple "print hi" script takes at least a minute. I have tested the uninstall and reinstall on a test Windows 2000...
4
3745
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just did a preload script. But then the user has to sit for 5 minutes waiting for 63 images to download! My images are about 640x480 and average 100kb. Is this too much for one page to load? Should I load my slideshow into differerent windows? If so,...
5
1426
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use the appointment collection to populate the calendar control. The performance getting the XML data is fine, but loading the data into the collection is slow. My question/problem is should I be using the collection, a dataset, or something else to...
0
1513
by: Phl | last post by:
Hi, I am trying to create an webform which loads usercontrols dyanamically. I know exactly what to load for some of these controls but for some, I dont want to load it until the user has press a button. The controls which I know I will need at page init gets their viewstate contents back properly per postback. However I am having a lot of troubles with keeping the contents of usercontrols which are
5
3802
Coldfire
by: Coldfire | last post by:
I am having problem with slow crystal report loading plus slow dataadapter.fill method here is my code string SelectCmd = "SELECT * FROM EnterInstituteInformation WHERE EnterInstituteInformation.InstituteID=" + ID; this.oleDbSelectCommand1.CommandText = SelectCmd; oleDbSelectCommand1.Connection = oleDbConnection1; oleDbDataAdapter1.SelectCommand = oleDbSelectCommand1;
5
2824
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
We have a page that is loading very slow. There is not a lot of data, not a lot of users are connected at the same time and the page does not produce an error, so I am not sure where to start to look for why it is slowing down. I thought about the DB first and added NOLOCK to a couple of stored procedures that were being run, but with no effect. Can someone offer some tips on where to start looking or how I can begin to diagnose this...
13
2531
by: mowsen | last post by:
Hello Group, i'm using a little "ajax" loader script to dynamically load files into different "div" tags on my main site. the code for this part looks like: function loader() { var args = loader.arguments; switch (args) { case
4
1871
by: jaykrish | last post by:
Hi guys Iam new to .net i got an interview and i cleared 2 interviews this is last stage. They have send me scenario.pls help me out in this scenario. This scenario involves a fictitious web-based ASP.NET/VB.NET patient registry application. The registry has several forms (also referred to as sections). The definition of the forms is stored in a relational database. The form is constructed on run-time by querying the database recursively to...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.