473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 17 '05 #1
5 1399
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 XmlSerialization (which is built around XmlReaders).

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

"Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
news:e8**************@TK2MSFTNGP12.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 17 '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.Appointment
Dim oAppointments As Calendar.Appointments
Dim doc As Xml.XPath.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
If it.Count > 0 Then
oAppointments = New Calendar.Appointments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appointment
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
oAppointment.Category = Mid(children.Current.Value, 1,
intIndex - 1)
oAppointment.Subject = Mid(children.Current.Value,
intIndex + 1)
Else
oAppointment.Subject = children.Current.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.StartTime = children.Current.Value
Case "dtend"
oAppointment.EndTime = children.Current.Value
Case "location"
oAppointment.Location = children.Current.Value
Case "alldayevent"
oAppointment.AllDayEvent = children.Current.Value
Case "reminderoffset"
oAppointment.ReminderOffset = children.Current.Value / 60
Case "description"
oAppointment.Body = children.Current.Value
End Select
End While
oAppointments.Add(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.Appointment)
mcolItems.Add(objNew)
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 lngReminderOffset As Long
Private objAttendies As Calendar.Attendies

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 lngReminderOffset
End Get
Set(ByVal Value As Long)
lngReminderOffset = Value
End Set
End Property

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

Sub New()
objAttendies = Calendar.Attendies.GetAttendies
End Sub
End Class
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:ue**************@TK2MSFTNGP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterator 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.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
Console.WriteLine(String.Format("Category {0}",
Mid(children.Current.Value, 1, intIndex - 1)))
Console.WriteLine(String.Format("subject {0}",
Mid(children.Current.Value, intIndex + 1)))
Else
children.Current.MoveToFirstChild()
Console.WriteLine(String.Format("subject {0}",
children.Current.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
news:uK**************@TK2MSFTNGP09.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 ConvertXMLtoAppointment(ByVal strXML As
String) As Calendar.Appointments
' this routine takes the XML stream and puts it into a
collection of appointments
Dim oAppointment As Calendar.Appointment
Dim oAppointments As Calendar.Appointments
Dim oXML As New Xml.XmlDocument
oXML.LoadXml(strXML)

Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(oXML.NameTable)
oNSManager.AddNamespace("a", "DAV:")

Dim oResponses As Xml.XmlNodeList =

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

Dim iResponseLoop As Int16
Dim iLoop As Int16
' Walk the response collection
If oResponses.Count > 0 Then
Try
'load collection
oAppointments = New Calendar.Appointments

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

For iLoop = 0 To oNode.ChildNodes.Count - 1
Select Case oNode.ChildNodes.Item(iLoop).Name
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1,
oNode.ChildNodes.Item(iLoop).InnerText, ":")

If intIndex > 0 Then
oAppointment.Category =
Mid(oNode.ChildNodes.Item(iLoop).InnerText, 1, intIndex - 1)
oAppointment.Subject =
Mid(oNode.ChildNodes.Item(iLoop).InnerText, intIndex + 1)
Else
oAppointment.Subject =
oNode.ChildNodes.Item(iLoop).InnerText
End If
intIndex = Nothing

Select Case oAppointment.Category
Case "Conference Call"
Case "Events"
Case "Meeting"
Case "Other"
Case "Personal"
Case "Vacation"
Case Else
oAppointment.Category = ""
oAppointment.Subject =
oNode.ChildNodes.Item(iLoop).InnerText
End Select
Case "dtstart"
oAppointment.StartTime =
oNode.ChildNodes.Item(iLoop).InnerText
Case "dtend"
oAppointment.EndTime =
oNode.ChildNodes.Item(iLoop).InnerText
Case "location"
oAppointment.Location =
oNode.ChildNodes.Item(iLoop).InnerText
Case "alldayevent"
oAppointment.AllDayEvent =
oNode.ChildNodes.Item(iLoop).InnerText
Case "reminderoffset"
oAppointment.ReminderOffset =
oNode.ChildNodes.Item(iLoop).InnerText / 60
Case "description"
oAppointment.Body =
oNode.ChildNodes.Item(iLoop).InnerText
End Select
Next
oAppointments.Add(oAppointment)
oAppointment = Nothing
Next
Catch ex As Exception
oAppointment = Nothing
Finally
iLoop = Nothing
iResponseLoop = Nothing
End Try
End If
oResponses = Nothing
ConvertXMLtoAppointment = 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:multistatus
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:"
xmlns:d="urn:schemas-microsoft-com:office:office"

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

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.EML</a:href><a:propstat><a:status
HTTP/1.1 200

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

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

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

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.EML</a:href><a:propstat><a:status>HTTP
/1.1 200

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

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

Thanks,
Kurt Bauer
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in message news:O6**************@tk2msftngp13.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 XmlSerialization (which is built around XmlReaders).

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

"Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
news:e8**************@TK2MSFTNGP12.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 17 '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****@NOSPAMtampabay.rr.com> wrote in message
news:ue**************@TK2MSFTNGP12.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.Appointment
Dim oAppointments As Calendar.Appointments
Dim doc As Xml.XPath.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
If it.Count > 0 Then
oAppointments = New Calendar.Appointments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appointment
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
oAppointment.Category = Mid(children.Current.Value, 1,
intIndex - 1)
oAppointment.Subject = Mid(children.Current.Value,
intIndex + 1)
Else
oAppointment.Subject = children.Current.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.StartTime = children.Current.Value
Case "dtend"
oAppointment.EndTime = children.Current.Value
Case "location"
oAppointment.Location = children.Current.Value
Case "alldayevent"
oAppointment.AllDayEvent = children.Current.Value
Case "reminderoffset"
oAppointment.ReminderOffset = children.Current.Value / 60
Case "description"
oAppointment.Body = children.Current.Value
End Select
End While
oAppointments.Add(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.Appointment)
mcolItems.Add(objNew)
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 lngReminderOffset As Long
Private objAttendies As Calendar.Attendies

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 lngReminderOffset
End Get
Set(ByVal Value As Long)
lngReminderOffset = Value
End Set
End Property

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

Sub New()
objAttendies = Calendar.Attendies.GetAttendies
End Sub
End Class
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:ue**************@TK2MSFTNGP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterator 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.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
Console.WriteLine(String.Format("Category {0}",
Mid(children.Current.Value, 1, intIndex - 1)))
Console.WriteLine(String.Format("subject {0}",
Mid(children.Current.Value, intIndex + 1)))
Else
children.Current.MoveToFirstChild()
Console.WriteLine(String.Format("subject {0}",
children.Current.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
news:uK**************@TK2MSFTNGP09.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 ConvertXMLtoAppointment(ByVal strXML As String) As Calendar.Appointments
' this routine takes the XML stream and puts it into a
collection of appointments
Dim oAppointment As Calendar.Appointment
Dim oAppointments As Calendar.Appointments
Dim oXML As New Xml.XmlDocument
oXML.LoadXml(strXML)

Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(oXML.NameTable)
oNSManager.AddNamespace("a", "DAV:")

Dim oResponses As Xml.XmlNodeList =

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

Dim iResponseLoop As Int16
Dim iLoop As Int16
' Walk the response collection
If oResponses.Count > 0 Then
Try
'load collection
oAppointments = New Calendar.Appointments

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

For iLoop = 0 To oNode.ChildNodes.Count - 1
Select Case oNode.ChildNodes.Item(iLoop).Name Case "subject"
Dim intIndex As Integer
intIndex = InStr(1,
oNode.ChildNodes.Item(iLoop).InnerText, ":")

If intIndex > 0 Then
oAppointment.Category =
Mid(oNode.ChildNodes.Item(iLoop).InnerText, 1, intIndex - 1)
oAppointment.Subject =
Mid(oNode.ChildNodes.Item(iLoop).InnerText, intIndex + 1)
Else
oAppointment.Subject =
oNode.ChildNodes.Item(iLoop).InnerText
End If
intIndex = Nothing

Select Case oAppointment.Category
Case "Conference Call"
Case "Events"
Case "Meeting"
Case "Other"
Case "Personal"
Case "Vacation"
Case Else
oAppointment.Category = ""
oAppointment.Subject =
oNode.ChildNodes.Item(iLoop).InnerText
End Select
Case "dtstart"
oAppointment.StartTime =
oNode.ChildNodes.Item(iLoop).InnerText
Case "dtend"
oAppointment.EndTime =
oNode.ChildNodes.Item(iLoop).InnerText
Case "location"
oAppointment.Location =
oNode.ChildNodes.Item(iLoop).InnerText
Case "alldayevent"
oAppointment.AllDayEvent =
oNode.ChildNodes.Item(iLoop).InnerText
Case "reminderoffset"
oAppointment.ReminderOffset =
oNode.ChildNodes.Item(iLoop).InnerText / 60
Case "description"
oAppointment.Body =
oNode.ChildNodes.Item(iLoop).InnerText
End Select
Next
oAppointments.Add(oAppointment)
oAppointment = Nothing
Next
Catch ex As Exception
oAppointment = Nothing
Finally
iLoop = Nothing
iResponseLoop = Nothing
End Try
End If
oResponses = Nothing
ConvertXMLtoAppointment = 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:multistatus
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" xmlns:d="urn:schemas-microsoft-com:office:office"

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

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.EML</a:href><a:propstat><a:status
>HTTP/1.1 200

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

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

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

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.EML</a:href><a:propstat><a:status>HTTP
/1.1 200

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

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

Thanks,
Kurt Bauer
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:O6**************@tk2msftngp13.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 XmlSerialization (which is built around XmlReaders).
>
> HTH,
> Christoph Schittko
> Software Architect, .NET Mentor
> MVP XML .NET
>
> "Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
> news:e8**************@TK2MSFTNGP12.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 17 '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******************@TK2MSFTNGP12.phx.gbl...
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****@NOSPAMtampabay.rr.com> wrote in message
news:ue**************@TK2MSFTNGP12.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.Appointment
Dim oAppointments As Calendar.Appointments
Dim doc As Xml.XPath.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
If it.Count > 0 Then
oAppointments = New Calendar.Appointments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appointment
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
oAppointment.Category = Mid(children.Current.Value, 1, intIndex - 1)
oAppointment.Subject = Mid(children.Current.Value,
intIndex + 1)
Else
oAppointment.Subject = children.Current.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.StartTime = children.Current.Value
Case "dtend"
oAppointment.EndTime = children.Current.Value
Case "location"
oAppointment.Location = children.Current.Value
Case "alldayevent"
oAppointment.AllDayEvent = children.Current.Value
Case "reminderoffset"
oAppointment.ReminderOffset = children.Current.Value / 60 Case "description"
oAppointment.Body = children.Current.Value
End Select
End While
oAppointments.Add(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.Appointment)
mcolItems.Add(objNew)
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 lngReminderOffset As Long
Private objAttendies As Calendar.Attendies

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 lngReminderOffset
End Get
Set(ByVal Value As Long)
lngReminderOffset = Value
End Set
End Property

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

Sub New()
objAttendies = Calendar.Attendies.GetAttendies
End Sub
End Class
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in message news:ue**************@TK2MSFTNGP10.phx.gbl...
Kurt,

try the XPathNavigator/XPathNodeIterator 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.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
' Walk the response collection
While it.MoveNext
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
Console.WriteLine(String.Format("Category {0}",
Mid(children.Current.Value, 1, intIndex - 1)))
Console.WriteLine(String.Format("subject {0}",
Mid(children.Current.Value, intIndex + 1)))
Else
children.Current.MoveToFirstChild()
Console.WriteLine(String.Format("subject {0}",
children.Current.Value))
End If
' ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET
"Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
news:uK**************@TK2MSFTNGP09.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 ConvertXMLtoAppointment(ByVal strXML As > String) As Calendar.Appointments
> ' this routine takes the XML stream and puts it into a
> collection of appointments
> Dim oAppointment As Calendar.Appointment
> Dim oAppointments As Calendar.Appointments
> Dim oXML As New Xml.XmlDocument
> oXML.LoadXml(strXML)
>
> Dim oNSManager As XmlNamespaceManager = New
> XmlNamespaceManager(oXML.NameTable)
> oNSManager.AddNamespace("a", "DAV:")
>
> Dim oResponses As Xml.XmlNodeList =
oXML.SelectNodes("//a:prop",
> oNSManager)
> oXML = Nothing
> oNSManager = Nothing
>
> Dim iResponseLoop As Int16
> Dim iLoop As Int16
> ' Walk the response collection
> If oResponses.Count > 0 Then
> Try
> 'load collection
> oAppointments = New Calendar.Appointments
>
> 'loop through each response
> For iResponseLoop = 0 To oResponses.Count - 1
> 'load appointment into collection
> Dim oNode As Xml.XmlNode
> oNode = oResponses.Item(iResponseLoop)
> oAppointment = New Calendar.Appointment
>
> For iLoop = 0 To oNode.ChildNodes.Count - 1
> Select Case

oNode.ChildNodes.Item(iLoop).Name
> Case "subject"
> Dim intIndex As Integer
> intIndex = InStr(1,
> oNode.ChildNodes.Item(iLoop).InnerText, ":")
>
> If intIndex > 0 Then
> oAppointment.Category =
> Mid(oNode.ChildNodes.Item(iLoop).InnerText, 1, intIndex - 1)
> oAppointment.Subject =
> Mid(oNode.ChildNodes.Item(iLoop).InnerText, intIndex + 1)
> Else
> oAppointment.Subject =
> oNode.ChildNodes.Item(iLoop).InnerText
> End If
> intIndex = Nothing
>
> Select Case oAppointment.Category > Case "Conference Call"
> Case "Events"
> Case "Meeting"
> Case "Other"
> Case "Personal"
> Case "Vacation"
> Case Else
> oAppointment.Category = "" > oAppointment.Subject =
> oNode.ChildNodes.Item(iLoop).InnerText
> End Select
> Case "dtstart"
> oAppointment.StartTime =
> oNode.ChildNodes.Item(iLoop).InnerText
> Case "dtend"
> oAppointment.EndTime =
> oNode.ChildNodes.Item(iLoop).InnerText
> Case "location"
> oAppointment.Location =
> oNode.ChildNodes.Item(iLoop).InnerText
> Case "alldayevent"
> oAppointment.AllDayEvent =
> oNode.ChildNodes.Item(iLoop).InnerText
> Case "reminderoffset"
> oAppointment.ReminderOffset =
> oNode.ChildNodes.Item(iLoop).InnerText / 60
> Case "description"
> oAppointment.Body =
> oNode.ChildNodes.Item(iLoop).InnerText
> End Select
> Next
> oAppointments.Add(oAppointment)
> oAppointment = Nothing
> Next
> Catch ex As Exception
> oAppointment = Nothing
> Finally
> iLoop = Nothing
> iResponseLoop = Nothing
> End Try
> End If
> oResponses = Nothing
> ConvertXMLtoAppointment = 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:multistatus
> xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" > xmlns:d="urn:schemas-microsoft-com:office:office"
>

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

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.EML</a:href><a:propstat><a:status
> >HTTP/1.1 200
>

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

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

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

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.EML</a:href><a:propstat><a:status>HTTP
> /1.1 200
>

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

b:dt="dateTime.tz">2003-07-28T04:00:00.000Z</dtend></a:prop></a:propstat></a
> :response></a:multistatus>
>
> Thanks,
> Kurt Bauer
>
>
> "Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote
in
> message news:O6**************@tk2msftngp13.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 XmlSerialization (which is built around XmlReaders).
> >
> > HTH,
> > Christoph Schittko
> > Software Architect, .NET Mentor
> > MVP XML .NET
> >
> > "Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
> > news:e8**************@TK2MSFTNGP12.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 17 '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****@NOSPAMtampabay.rr.com> wrote in message
news:uo**************@tk2msftngp13.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******************@TK2MSFTNGP12.phx.gbl...
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****@NOSPAMtampabay.rr.com> wrote in message
news:ue**************@TK2MSFTNGP12.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.Appointment
Dim oAppointments As Calendar.Appointments
Dim doc As Xml.XPath.XPathDocument = New Xml.XPath.XPathDocument(New
XmlTextReader(New System.IO.StringReader(strXML)))
Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
Dim oNSManager As XmlNamespaceManager = New
XmlNamespaceManager(nav.NameTable)
Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop")
oNSManager.AddNamespace("a", "DAV:")
expression.SetContext(oNSManager)
Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
If it.Count > 0 Then
oAppointments = New Calendar.Appointments
' Walk the response collection
While it.MoveNext
oAppointment = New Calendar.Appointment
Dim appointments As Xml.XPath.XPathNavigator = it.Current
Dim children As Xml.XPath.XPathNodeIterator =
appointments.SelectChildren(XPath.XPathNodeType.El ement)
While children.MoveNext
Select Case children.Current.LocalName
Case "subject"
Dim intIndex As Integer
intIndex = InStr(1, children.Current.Value, ":")
If intIndex > 0 Then
oAppointment.Category =
Mid(children.Current.Value, 1, intIndex - 1)
oAppointment.Subject = Mid(children.Current.Value,
intIndex + 1)
Else
oAppointment.Subject = children.Current.Value
End If
intIndex = Nothing
Case "dtstart"
oAppointment.StartTime = children.Current.Value
Case "dtend"
oAppointment.EndTime = children.Current.Value
Case "location"
oAppointment.Location = children.Current.Value
Case "alldayevent"
oAppointment.AllDayEvent = children.Current.Value
Case "reminderoffset"
oAppointment.ReminderOffset = children.Current.Value / 60 Case "description"
oAppointment.Body = children.Current.Value
End Select
End While
oAppointments.Add(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.Appointment)
mcolItems.Add(objNew)
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 lngReminderOffset As Long
Private objAttendies As Calendar.Attendies

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 lngReminderOffset
End Get
Set(ByVal Value As Long)
lngReminderOffset = Value
End Set
End Property

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

Sub New()
objAttendies = Calendar.Attendies.GetAttendies
End Sub
End Class
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote
in message news:ue**************@TK2MSFTNGP10.phx.gbl...
> Kurt,
>
> try the XPathNavigator/XPathNodeIterator 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.XPathDocument = New Xml.XPath.XPathDocument(New
> XmlTextReader(New System.IO.StringReader(strXML)))
> Dim nav As Xml.XPath.XPathNavigator = doc.CreateNavigator()
> Dim oNSManager As XmlNamespaceManager = New
> XmlNamespaceManager(nav.NameTable)
> Dim expression As Xml.XPath.XPathExpression = nav.Compile("//a:prop") > oNSManager.AddNamespace("a", "DAV:")
> expression.SetContext(oNSManager)
> Dim it As Xml.XPath.XPathNodeIterator = nav.Select(expression)
> ' Walk the response collection
> While it.MoveNext
> Dim appointments As Xml.XPath.XPathNavigator = it.Current
> Dim children As Xml.XPath.XPathNodeIterator =
> appointments.SelectChildren(XPath.XPathNodeType.El ement)
> While children.MoveNext
> Select Case children.Current.LocalName
> Case "subject"
> Dim intIndex As Integer
> intIndex = InStr(1, children.Current.Value, ":")
> If intIndex > 0 Then
> Console.WriteLine(String.Format("Category {0}",
> Mid(children.Current.Value, 1, intIndex - 1)))
> Console.WriteLine(String.Format("subject {0}",
> Mid(children.Current.Value, intIndex + 1)))
> Else
> children.Current.MoveToFirstChild()
> Console.WriteLine(String.Format("subject {0}",
> children.Current.Value))
> End If
> ' ...
>
> HTH,
> Christoph Schittko
> Software Architect, .NET Mentor
> MS MVP XML .NET
> "Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
> news:uK**************@TK2MSFTNGP09.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 ConvertXMLtoAppointment(ByVal strXML As
> > String) As Calendar.Appointments
> > ' this routine takes the XML stream and puts it into a
> > collection of appointments
> > Dim oAppointment As Calendar.Appointment
> > Dim oAppointments As Calendar.Appointments
> > Dim oXML As New Xml.XmlDocument
> > oXML.LoadXml(strXML)
> >
> > Dim oNSManager As XmlNamespaceManager = New
> > XmlNamespaceManager(oXML.NameTable)
> > oNSManager.AddNamespace("a", "DAV:")
> >
> > Dim oResponses As Xml.XmlNodeList =
> oXML.SelectNodes("//a:prop",
> > oNSManager)
> > oXML = Nothing
> > oNSManager = Nothing
> >
> > Dim iResponseLoop As Int16
> > Dim iLoop As Int16
> > ' Walk the response collection
> > If oResponses.Count > 0 Then
> > Try
> > 'load collection
> > oAppointments = New Calendar.Appointments
> >
> > 'loop through each response
> > For iResponseLoop = 0 To oResponses.Count - 1
> > 'load appointment into collection
> > Dim oNode As Xml.XmlNode
> > oNode = oResponses.Item(iResponseLoop)
> > oAppointment = New Calendar.Appointment
> >
> > For iLoop = 0 To oNode.ChildNodes.Count -
1 > > Select Case
oNode.ChildNodes.Item(iLoop).Name
> > Case "subject"
> > Dim intIndex As Integer
> > intIndex = InStr(1,
> > oNode.ChildNodes.Item(iLoop).InnerText, ":")
> >
> > If intIndex > 0 Then
> > oAppointment.Category =
> > Mid(oNode.ChildNodes.Item(iLoop).InnerText, 1, intIndex - 1)
> > oAppointment.Subject =
> > Mid(oNode.ChildNodes.Item(iLoop).InnerText, intIndex + 1)
> > Else
> > oAppointment.Subject =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > End If
> > intIndex = Nothing
> >
> > Select Case oAppointment.Category > > Case "Conference Call"
> > Case "Events"
> > Case "Meeting"
> > Case "Other"
> > Case "Personal"
> > Case "Vacation"
> > Case Else
> > oAppointment.Category = ""
> > oAppointment.Subject =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > End Select
> > Case "dtstart"
> > oAppointment.StartTime =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > Case "dtend"
> > oAppointment.EndTime =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > Case "location"
> > oAppointment.Location =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > Case "alldayevent"
> > oAppointment.AllDayEvent =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > Case "reminderoffset"
> > oAppointment.ReminderOffset =
> > oNode.ChildNodes.Item(iLoop).InnerText / 60
> > Case "description"
> > oAppointment.Body =
> > oNode.ChildNodes.Item(iLoop).InnerText
> > End Select
> > Next
> > oAppointments.Add(oAppointment)
> > oAppointment = Nothing
> > Next
> > Catch ex As Exception
> > oAppointment = Nothing
> > Finally
> > iLoop = Nothing
> > iResponseLoop = Nothing
> > End Try
> > End If
> > oResponses = Nothing
> > ConvertXMLtoAppointment = 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:multistatus
> > xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:"
> > xmlns:d="urn:schemas-microsoft-com:office:office"
> >
>

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

dar/{D1A44985-AD7A-41E9-97BA-A6245517AB4C}.EML</a:href><a:propstat><a:status
> > >HTTP/1.1 200
> >
>

OK</a:status><a:prop><url>http://localhost/exchange/kurtbauer/Calendar/{D1A4
> > 4985-AD7A-41E9-97BA-A6245517AB4C}.EML</url><subject>Conference

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

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

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

FF5A919B-0FB0-4AF0-8013-42F4CC5F3B4D}.EML</a:href><a:propstat><a:status>HTTP
> > /1.1 200
> >
>

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

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

wrote
in
> > message news:O6**************@tk2msftngp13.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 XmlSerialization (which is built around
XmlReaders). > > >
> > > HTH,
> > > Christoph Schittko
> > > Software Architect, .NET Mentor
> > > MVP XML .NET
> > >
> > > "Kurt Bauer" <kb****@NOSPAMtampabay.rr.com> wrote in message
> > > news:e8**************@TK2MSFTNGP12.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 17 '05 #6

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

Similar topics

1
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. ...
0
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...
4
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...
5
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...
2
by: JC Carette | last post by:
Hello I am experiencing extremely long time for loading a windows form in my Visual C++ .NET project This Windows form has just 40 labels, 4 checkBoxes, 2 buttons and 11 numericUpDown. It takes...
0
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...
5
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...
5
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...
13
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 =...
4
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.