Question : Print .xml document....ASP

Are there any simple templates to demonstrate reading an .xml file, grouping certain records together and printing them out?  I have an inventory file that I want to print in format layout.  I do not want to do this with PHP.  ASP would be great.

Answer : Print .xml document....ASP

I'll leave the formatting to you, but the attached files should get you well on your way, in summary it will:
Load an XSLT (XML transformation sheet) and apply it against the HTML to sort the items by category,
It will then select all nodes that don't have hide set to true
It will then loop through each of these output category headings as they change and list upto 3 items per category.

The code below is for the .asp file, the attached file is the XSL sheet. You will likely need to change the paths to the XSL & XML documents these are set in the asp on lines 5(XSL), 13(XML) if they are in the webroot then leave the Server.MapPath in as this tells it to find the actual path based on its location in the webserver root directory. If they are not in the webroot then take out the server.mappath and put the full path in the quotes (i.e. "c:\inetpub\data\test.xml")
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
<%
Dim objXSLT : Set objXSLT = Server.CreateObject("Msxml2.DOMDocument.6.0")
objXSLT.ASync = False
objXSLT.setProperty "SelectionLanguage","XPath"
If Not objXSLT.Load(Server.MapPath("/Q26420449/sort.xsl")) Then
	Response.Write "Error loading XSLT: " & objXSLT.parseError.reason
	Response.End
End If

Dim objXML : Set objXML = Server.CreateObject("Msxml2.DOMDocument.6.0")
objXML.ASync = False
objXML.setProperty "SelectionLanguage","XPath"
If Not objXML.Load(Server.MapPath("/Q26420449/src.xml")) Then
	Response.Write "Error loading XML: " & objXML.parseError.reason
	Response.End
End If

strSortedXML = objXML.transformNode(objXSLT)
If Not objXML.LoadXML(strSortedXML) Then
	Response.Write "Error loading XML: " & objXML.parseError.reason
	Response.End
End If


Dim dictCats : Set dictCats = Server.CreateObject("Scripting.Dictionary")

Set objResults = objXML.selectNodes("//row[hide!='true']")
If objResults.length > 0 Then
	Dim objNode, objSubNode, strCurrentCat, intCatCount
	strCurrentCat = ""
	intCatCount = 0
	Do
		Set objNode = objResults.nextNode()
		If objNode Is Nothing Then Exit Do
		
		Set objSubNode = objNode.selectSingleNode("category")
		If Not objSubNode Is Nothing Then
			If Not strCurrentCat = LCase(objSubNode.text) Then
				intCatCount = 0
				strCurrentCat = LCase(objSubNode.text)
				Response.Write "<h2>" & strCurrentCat & "</h2>"
			End If
			
			intCatCount = intCatCount + 1
			If intCatCount < 4 Then
				strNodeName = "pname" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "psubname" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "lprice1" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "lprice2" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "lprice3" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "mprice1" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "mprice2" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "mprice3" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "sprice1" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "sprice2" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				strNodeName = "sprice3" : Response.Write strNodeName & ": " & getNodeValue(objNode.selectSingleNode(strNodeName)) & "<br />"
				Response.Write "<hr />"
			End If
			
		End If
		
	Loop
	
End If

Function getNodeValue(objNode)
	If Not objNode Is Nothing Then
		getNodeValue=objNode.text
	Else
		getNodeValue=""
	End if
End Function

Response.Write TypeName(objResults)

Set objResults = Nothing
Set objXML = Nothing
%>
 
XSL sheet to order rows by category
 
Random Solutions  
 
programming4us programming4us