Developer forum

Forum » Development » Getting XML from Dynamicweb for use in ie flash.

Getting XML from Dynamicweb for use in ie flash.

Nicolai Høeg Pedersen
Reply

Lately I've gotten some questions on how to get some data from Dynamicweb in XML for use in Flash things. I've mocked up a quick example of how to do it with custom code. This is the page_load event of Default.aspx.vb/cs in the root of a Custom Modules project.


 


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load




'Set a timer to monitor performance




Dim StartTime As Long = DateTime.Now.Ticks




'Initiate the pageview object that handles a Page view in Dynamicweb




Dim Pageview As New Dynamicweb.Frontend.PageView




'Create an instance of the eventhandler object and attach it to the custom module event




Dim objCustModuleHandler As New CustomModuleHandler




AddHandler Pageview.Content.CMEventHandler, AddressOf objCustModuleHandler.GetCustomModule




'Load data, templates and settings in the pageview object




Pageview.Load()




If Pageview.TemplatePage.TagExist("MyTag") Then




Pageview.TemplatePage.SetTemplateValue("MyTag", "MyValue")




End If




 




 




'Base.we(SolutionModuleGrid.getGrid())




'If Pageview.User.LoggedIn Then




'End If




'Hooking to the navigation system




If Not String.IsNullOrEmpty(Base.Request("xml")) Then




Dim NavXmlDoc As XmlDocument




Dim Nav As New Frontend.XMLNavigation(Pageview)




NavXmlDoc = Nav.XML(0, 1, 99, Frontend.XMLNavigation.Expand.All)




Response.Clear()




Response.ContentType = "text/xml"




Response.Write(NavXmlDoc.OuterXml)




Response.End()




End If




'Getting one news as xml




'NewsXML should contain the ID of the newsItem that is needed




'http://vbclassic.local.dynamicweb.dk/?NewsXML=1




If Not String.IsNullOrEmpty(Base.Request("NewsXML")) Then




Dim newsId As Integer = Base.ChkNumber(Base.Request("NewsXML"))




Dim dt As DataTable = Database.getDataSet("SELECT * FROM News WHERE NewsID = " & newsId).Tables(0)




Dim myStringuilder As New System.Text.StringBuilder




Dim myStream As New System.IO.StringWriter(myStringuilder)




dt.WriteXml(myStream)




Response.Clear()




Response.ContentType = "text/xml"




Response.Write(myStream.GetStringBuilder.ToString)




Response.End()




End If




'Getting a list of news as xml




'NewsXML should contain the ID of the newsItem that is needed




'http://vbclassic.local.dynamicweb.dk/?NewsCategoryXML=1




If Not String.IsNullOrEmpty(Base.Request("NewsCategoryXML")) Then




Dim NewsCategoryID As Integer = Base.ChkNumber(Base.Request("NewsCategoryXML"))




Dim dt As DataTable = Database.getDataSet("SELECT * FROM News WHERE NewsCategoryID = " & NewsCategoryID).Tables(0)




Dim myStringuilder As New System.Text.StringBuilder




Dim myStream As New System.IO.StringWriter(myStringuilder)




dt.WriteXml(myStream)




Response.Clear()




Response.ContentType = "text/xml"




Response.Write(myStream.GetStringBuilder.ToString)




Response.End()




End If




'Getting one paragraph as xml




'ParagraphXML should contain the ID of the paragraph that is needed




'http://vbclassic.local.dynamicweb.dk/?ParagraphXML=1




If Not String.IsNullOrEmpty(Base.Request("ParagraphXML")) Then




Dim ParagraphId As Integer = Base.ChkNumber(Base.Request("ParagraphXML"))




Dim dt As DataTable = Database.getDataSet("SELECT * FROM Paragraph WHERE ParagraphID = " & ParagraphId).Tables(0)




Dim myStringuilder As New System.Text.StringBuilder




Dim myStream As New System.IO.StringWriter(myStringuilder)




dt.WriteXml(myStream)




Response.Clear()




Response.ContentType = "text/xml"




Response.Write(myStream.GetStringBuilder.ToString)




Response.End()




End If




'NavXmlDoc.PreserveWhitespace = False




'Dim resultingHtml As String = Base.XmlXsltParse(NavXmlDoc, "~/Files/Templates/Navigation/" & XSLTTemplate)




'Pageview.TemplatePage.SetTemplateValue("SpaanjaarsNavigation", resultingHtml)




'dynamicweb.Core.Paragraph.GetParagraphsForPageID()




'Render the data of the pageview object and place the resulting HTML in the output-literal




Dim GlobalTemplate As New Dynamicweb.Templatev2.Template




GlobalTemplate.Html = Pageview.Output




GlobalTemplate.SetTag("GlobalPageID", Pageview.ID)




Output.Text = GlobalTemplate.Output




'Output.Text = Pageview.Output()




'Dim pvCtl As New PageviewControl




'Output.Controls.Add(pvCtl)




'pvCtl.Pageview = Pageview




'pvCtl.LoadControl("/WebUserControl1.ascx", "Control1")




'Collect the last performance counter and print if requested




Pageview.Execution.Add("After output")




Dim strDebug As String = Base.ChkString(HttpContext.Current.Request.QueryString("Debug"))




If strDebug = "True" Then




Status.Text = Server.HtmlEncode("") & Pageview.Execution.getExecutionTable() & Pageview.OutputPages()




Else




Status.Text = ""




End If




End Sub


Replies

 

You must be logged in to post in the forum