Public Function DisplaySiteMap() As String
Dim tmpString As New StringBuilder
Dim objDB As New ZipCM.Database
Dim objSet As New ZipCM.Settings
Dim strXml As String = ""
objSet.SiteSettings()
With objDB
.ConnString = Common.ConnString
.CmdType = 1
.Query = "Select a.pageID, a.pageTitle, a.pageLink, " & _
"(Select b.pageID, b.pageTitle, b.pageLink From MainSitePages b Where b.parentID = a.pageID For XML Path('SubPage'), Type) As SubPages " & _
"From MainSitePages a " & _
"Where a.siteID = @SiteID " & _
"For XML Path('Page'), Root('Pages')"
.ParamNames = New String() {"@SiteID"}
.Values = New String() {objSet.SiteID}
.ExecuteDataReader()
If .TotalRecords > 0 Then
strXml = .ReturnValues(0, 0)(1)
Else
strXml = ""
End If
End With
objSet = Nothing
objDB = Nothing
Try
Dim objXml As New XmlDocument
Dim objNode As XmlNode
Dim nodeCount As Long = 0
objXml.LoadXml(strXml)
objNode = objXml.SelectSingleNode("//Pages")
nodeCount = objNode.ChildNodes.Count
objNode = Nothing
objXml = Nothing
tmpString.Append("<h1>" & nodeCount & " Pages</h1>")
Catch ex As Exception
tmpString.Append(ex.Message & "<pre>" & strXml & "</pre>")
End Try
If tmpString.Length > 0 Then
Return tmpString.ToString()
Else
Return ""
End If
tmpString = Nothing
End Function
|