473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Using XML Problem

I want the ASP page retrieves data from XML file and put in table. However,
is it possible that the ASP code doesn't know the look of XML file
structure? The following is my ASP code and XML data file. If more levels
are added in XML file, I need to change ASP code as well. i.e. For every
additional level in XML file, I need to add an additional loop in ASP page.

My question is: is it possible that ASP code is unchanged, even XML file
structure has changed. I just want the ASP code traverses the XML file can
print out all data in the table.

Please advise. Thanks!

=============== =============== =============== =============== ==
<%
Sub GetXMLData(link )
Dim xml
Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
xml.async = False
xml.load(Server .MapPath(link))
Dim root
Set root = xml.documentEle ment
%>
<table border="1">
<th>name</th><th>value</th>
<tbody>
<%
Dim name, url, thisChild
For I = 0 TO (root.childNode s.length - 1) '# level2
Set thisChild = root.childNodes (I)
For J = 0 TO (thisChild.chil dNodes.length - 1) '# level 3
Set thisChild2 = thisChild.child Nodes(J)
name = thisChild2.chil dNodes(0).Text
value = thisChild2.chil dNodes(1).Text
%>
<TR><TD><%= name %></TD><TD><%= value %></TD></TR>
<% Next %>
<% Next %>
</tbody></table>
<%
End Sub
%>

<%
Call GetXMLData("xml data.xml")
%>

=============== =============== =============== =============== ==
<!-- xmldata.xml -->

<?xml version="1.0"?>
<level1>
<level2>
<level3>
<name>name1</name>
<value>value1 </value>
</level3>
<level3>
<name>name2</name>
<value>value2 </value>
</level3>
</level2>
<level2>
<level3>
<name>name3</name>
<value>value3 </value>
</level3>
</level2>
</level1>


Jul 19 '05 #1
5 5821
ljb
You are making your life too hard. Use XSL to output the table. You will
need a variation of this using MSXML 4.0

Set xml = CreateObject("M sxml2.DOMDocume nt.4.0")
Set xsl = CreateObject("M sxml2.DOMDocume nt.4.0")

xml.async = False
xsl.async = false

xml.Load "xmldata.xm l"
xsl.Load "name table.xsl"

set ofile = CreateObject("A DODB.Stream")
ofile.Type = 2
ofile.Charset = "Windows-1252"
ofile.LineSepar ator = -1
ofile.open

xml.transformNo deToObject xsl, ofile 'produces UTF-8

ofile.SaveToFil e "name table.htm", 2
"Matt" <ma*******@hotm ail.com> wrote in message
news:uZ******** ******@TK2MSFTN GP12.phx.gbl...
I want the ASP page retrieves data from XML file and put in table. However, is it possible that the ASP code doesn't know the look of XML file
structure? The following is my ASP code and XML data file. If more levels
are added in XML file, I need to change ASP code as well. i.e. For every
additional level in XML file, I need to add an additional loop in ASP page.
My question is: is it possible that ASP code is unchanged, even XML file
structure has changed. I just want the ASP code traverses the XML file can
print out all data in the table.

Please advise. Thanks!

=============== =============== =============== =============== ==
<%
Sub GetXMLData(link )
Dim xml
Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
xml.async = False
xml.load(Server .MapPath(link))
Dim root
Set root = xml.documentEle ment
%>
<table border="1">
<th>name</th><th>value</th>
<tbody>
<%
Dim name, url, thisChild
For I = 0 TO (root.childNode s.length - 1) '# level2
Set thisChild = root.childNodes (I)
For J = 0 TO (thisChild.chil dNodes.length - 1) '# level 3
Set thisChild2 = thisChild.child Nodes(J)
name = thisChild2.chil dNodes(0).Text
value = thisChild2.chil dNodes(1).Text
%>
<TR><TD><%= name %></TD><TD><%= value %></TD></TR>
<% Next %>
<% Next %>
</tbody></table>
<%
End Sub
%>

<%
Call GetXMLData("xml data.xml")
%>

=============== =============== =============== =============== ==
<!-- xmldata.xml -->

<?xml version="1.0"?>
<level1>
<level2>
<level3>
<name>name1</name>
<value>value1 </value>
</level3>
<level3>
<name>name2</name>
<value>value2 </value>
</level3>
</level2>
<level2>
<level3>
<name>name3</name>
<value>value3 </value>
</level3>
</level2>
</level1>

Jul 19 '05 #2
ljb
I'm not sure I understand your question. ASP is used to generate an HTML or
other stream that is sent to the requesting application. The whole HTML
document is generated with each request. Perhaps some of it could come from
include files that don't change.

I'm not an expert in XML/XSL. They are over in the microsoft.publi c.xsl news
group. However I use it whenever I can. Perhaps xml.transformNo deToObject or
something similar could be directed to a response.write and a file not
created.

You should be able to run the vbscript from my earlier message and this XSL
file from your desktop and experiment with it. If your level numbers change
the XSL will need to be adjusted unless someone can show us a more generic
way of doing it and I'm sure someone can.

------------"name table.xsl"-------------

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:s chemas-microsoft-com:xslt">

<xsl:output method="html" encoding="UTF-8" indent="yes" />

<xsl:template match="/">
<html>
<body>
<table>

<xsl:for-each select="//level3">
<tr>
<td><xsl:valu e-of select="name" /></td>
<td><xsl:valu e-of select="value" /></td>
</tr>
</xsl:for-each>

</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>
Jul 19 '05 #3
When I try to run, there is error for 'Msxml2.DOMDocu ment.4.0'

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'Msxml2.DOMDocu ment.4.0'

any ideas?
Jul 19 '05 #4
Are you sure you have MSXML4 installed?

Try "Msxml2.DOMDocu ment"

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Matt" <an*******@disc ussions.microso ft.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
When I try to run, there is error for 'Msxml2.DOMDocu ment.4.0'

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'Msxml2.DOMDocu ment.4.0'

any ideas?

Jul 19 '05 #5
ljb
Try Msxml2.DOMDocum ent.3.0 or Msxml2.DOMDocum ent. If you have IE6 installed
you should have MSXML3 also. I verified the transform works in 3 but some
earlier versions of MSXML will not.

"Matt" <an*******@disc ussions.microso ft.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
When I try to run, there is error for 'Msxml2.DOMDocu ment.4.0'

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'Msxml2.DOMDocu ment.4.0'

any ideas?

Jul 19 '05 #6

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

Similar topics

7
2309
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site. The only reason I know that is happening is because I keep track of the pages executed by the user to see how they have traversed the site. Has anyone every seen anything like this before? Regards, Aaron Prohaska
9
2821
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
12
2060
by: bj7lewis | last post by:
I am working on a project I want to add a few files as resource to access(copy them to FS and use) at runtime. So far in VS.NET IDE, I Add Files to the project and set its Build Action to Embedded Resource... Now where should look next... Any help...
4
1227
by: zubair | last post by:
Hello everyone! I have uploaded my site on a webserver. Some times it works fine but some time it gives error "Null Object reference exception". The same site on my local server works just fine. When I change the "global.ascx" and ".dll" file in "bin" directory, it starts working fine but after some time, same problem arises again :(. Can any one help me plz in figuring out the problem, and I wud highly appreciate your suggestions and...
5
2734
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
8
9757
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
20
2509
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using insert-statements. after initalizing and starting postgres 7.4 on a different port and datadirectory, i tried to import the sql-dump with the copy statements. this import fails, but importing the dump-file with inserts took a long time but was...
16
4922
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
6
3271
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls to the function in the container. I allocate (and free in c) arrays to get garbage collection in both C and C#. After a few seconds I get an exception. I assume GarbageCollector moves the delegate (or collects is) and when I don't find it in C...
5
2004
by: Vibhesh | last post by:
I am facing problem with TimeSpan structure when DirectX is used. Following is the sample code that causes the problem: *************************************************************************************************************** { ........................... PrintTimeSpanProblem(); device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); PrintTimeSpanProblem();
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.