Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Thread Prev - XML to HTML
Re: XML to HTML
Date: 10/14/2004 10:49:00 AM
"Payal" <ppatel@f...> wrote in message news:83aae981.0410131123.25790b36@p...... > Hi, I have a XML code that needs to be shown in HTML/ASP format > without using XSL. Diffremt XML files will have diffrent number of > nodes and I have to write one standard code to convert all xml data in > HTML in tabular format. > > Is it possible to do? Any help is highly appriciated. > > -Payal You need to use server side coding for parsing the XML data and format them into HTML layout. This is sample code: Dim xmlObj set xmlObj = Server.CreateObject("Msxml2.DOMDocument.4.0") xmlObj.async = false IF xmlObj.load("d:\R_DSource\ddd.xml") = FALSE THEN Set xmlObj = nothing Response.Write "XML transformation failed." Response.end END IF set rootElement = xmlObj.documentElement Set objNodeList = rootElement.selectNodes("JobProperties") For i = 0 To (objNodeList.length - 1) Set objJobNumber = objNodeList.Item(i).selectNodes("JobNumber") JobNumber = objJobNumber.Item(0).Text Response.Write "JobNumber->" & JobNumber & "<BR>" Set objJobStartDate = objNodeList.Item(i).selectNodes("JobStartDate") JobStartDate = objJobStartDate.Item(0).Text Response.Write "JobStartDate->" & JobStartDate & "<BR>" Set objJobStartDate = nothing Set objJobNumber = nothing Next Set objNodeList = nothing However, I would suggest you to use XSLT to transform the XML data at server as it is much much powerful and faster then the method shown in sample code above.