473,698 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML/ASP Help Needed

I am new to XML, but not ASP.
I have the following XML that I load via
Dim xml
Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
xml.async = False
xml.loadXML xmldom.xml
<deals><escanof fers><escanoffe r offerid="3743" itemnumber="502 022"
upc="4300094509 " dealamt="0.20" begindate="03/01/2006"
enddate="03/30/2006" returnby="02/28/2006" selectionlength ="14"
maxretail="0.00 " /></escanoffers></deals>
I need to parse it, getting all the attributes out, using ASP.
AHIA
Larry...

Feb 1 '06 #1
16 2355
lr*****@gmail.c om wrote:
I am new to XML, but not ASP.
I have the following XML that I load via
Dim xml
Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
xml.async = False
xml.loadXML xmldom.xml
<deals><escanof fers><escanoffe r offerid="3743" itemnumber="502 022"
upc="4300094509 " dealamt="0.20" begindate="03/01/2006"
enddate="03/30/2006" returnby="02/28/2006" selectionlength ="14"
maxretail="0.00 " /></escanoffers></deals>
I need to parse it, getting all the attributes out, using ASP.


You mean "using vbscript" don't you? or are you using jscript in your asp
page?

Let's assume you want to put the attribute values into a Dictionary object:

dim d, node, attrs, attr, i
set d = createobject("s cripting.dictio nary")
set node = nothing
set node = xml.selectsingl enode("/deals/escanoffers/escanoffer")
if not node is nothing then
set attrs = node.attributes
for i = attrs.length-1
set attr=attrs.item (i)
d.add attr.nodename, attr.nodevalue
next
end if

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 1 '06 #2
Bob,

Thanks for the response.

Should the FOR line read....
for i = 0 to attrs.length-1

The script is not making it past
if not node is nothing then

I added the last two lines
set attr=attrs.item (i)
response.write "nodename:" & attr.nodename
response.write "nodevalue: " & attr.nodevalue

I need to display the data in the XML doc, is this syntax correct?

Also, there are several escanoffer within escanoffers.

TIA,
Larry...

Feb 1 '06 #3
lr*****@gmail.c om wrote:
Bob,

Thanks for the response.

Should the FOR line read....
for i = 0 to attrs.length-1
Yes
The script is not making it past
if not node is nothing then
That means your actual xml is different from the example xml you showed me.
The selectsinglenod e method is not finding that node.
I added the last two lines
set attr=attrs.item (i)
response.write "nodename:" & attr.nodename
response.write "nodevalue: " & attr.nodevalue

I need to display the data in the XML doc, is this syntax correct?
Seems to be. You probably want to add some <BR>s
Also, there are several escanoffer within escanoffers.

Then you need to modify the example to:
dim nodes, node, attrs, attr, i
set nodes = nothing
set node = xml.selectnodes ("/deals/escanoffers")
if not nodes is nothing then
for i = 0 to nodes.length - 1
set node = nodes.nextnode
set attrs = node.attributes
for i = attrs.length-1
set attr=attrs.item (i)
response.write "nodename:" & attr.nodename
response.write "nodevalue: " & attr.nodevalue
next
next
end if
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 1 '06 #4
Below is the entire XML doc from IE that is displayed when
Set xml = Server.CreateOb ject("Msxml2.DO MDocument.3.0")
xml.setProperty "SelectionLangu age", "XPath"
xml.async = False
xml.loadXML xmldom.xml
Response.write( xml.xml)
is executed.

I am still not getting past
if not nodes is nothing then

AHIA,
Larry....

PS - thanks for your patients. I am new to XML & very very confused at
this point. Can you recommend any books that will point me in the
right direction??

~_~_~_~Start XML~_~_~_~
<?xml version="1.0"?>
<soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"><soa p:Body><F
xmlns="http://tempuri.org/AGLinkiDataHost er/AGLinkiDataHost "><RetrieveProm otionalOpportun itiesListResult >&lt;deals&gt;& lt;escanoffers& gt;&lt;escanoff er
offerid="3743" itemnumber="502 022" upc="4300094509 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3747" itemnumber="502 030" upc="4300094502 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3989" itemnumber="553 824" upc="1600069320 " dealamt="0.77"
begindate="03/01/2006" enddate="04/01/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3994" itemnumber="556 823" upc="1600066510 " dealamt="0.60"
begindate="03/01/2006" enddate="04/01/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="4000" itemnumber="557 617" upc="1600068870 " dealamt="0.82"
begindate="03/01/2006" enddate="04/01/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="4004" itemnumber="558 060" upc="1600067440 " dealamt="0.58"
begindate="03/01/2006" enddate="04/01/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="4010" itemnumber="558 249" upc="1600064670 " dealamt="0.82"
begindate="03/01/2006" enddate="04/01/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3787" itemnumber="502 774" upc="4300097199 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3750" itemnumber="502 049" upc="4300094511 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3752" itemnumber="502 057" upc="4300095019 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3755" itemnumber="502 065" upc="4300095022 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3762" itemnumber="502 197" upc="4300094520 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3765" itemnumber="502 332" upc="4300095077 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3767" itemnumber="502 340" upc="4300094963 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3769" itemnumber="502 359" upc="4300095085 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3772" itemnumber="502 383" upc="4300095016 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3776" itemnumber="502 472" upc="4300095009 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3780" itemnumber="502 510" upc="4300095025 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3781" itemnumber="502 553" upc="4300095023 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 " /&gt;&lt;escanof fer
offerid="3785" itemnumber="502 561" upc="4300094541 " dealamt="0.20"
begindate="03/01/2006" enddate="03/30/2006" returnby="02/28/2006"
selectionlength ="14" maxretail="0.00 "
/&gt;&lt;/escanoffers&gt; &lt;/deals&gt;</RetrievePromoti onalOpportuniti esListResult></RetrievePromoti onalOpportuniti esListResponse> </soap:Body></soap:Envelope>
~_~_~_~End XML~_~_~_~

Feb 1 '06 #5
lr*****@gmail.c om wrote:
Below is the entire XML doc from IE that is displayed when
Set xml = Server.CreateOb ject("Msxml2.DO MDocument.3.0")
xml.setProperty "SelectionLangu age", "XPath"
xml.async = False
xml.loadXML xmldom.xml
Response.write( xml.xml)
is executed.

I am still not getting past
if not nodes is nothing then

AHIA,
Larry....

PS - thanks for your patients. I am new to XML & very very confused
at this point. Can you recommend any books that will point me in the
right direction??
No. All I've used is the msdn documentation - msdn.microsoft. com/library
~_~_~_~Start XML~_~_~_~ <RetrievePromot ionalOpportunit iesListResult>& lt;deals&gt;&lt ;escanoffers&gt ;
&lt;escanoff er offerid="3743" itemnumber="502 022" upc="4300094509 " dealamt="0.20"


Something is strange here. Some htmlencoding is occurring somewhere. Is this
really what it looks like? What about when you View Source? Do the &lt;
become < ?
It looks like the xml is really:
<RetrievePromot ionalOpportunit iesListResponse ><RetrievePromo tionalOpportuni t
iesListResult>< deals><escanoff ers>
etc.

So that means the xpath used in the selectnodes statement should be

dim path
path="/RetrievePromoti onalOpportuniti esListResponse" & _
"/RetrievePromoti onalOpportuniti esListResult/deals" & _
"/escanoffers/escanoffer"
set node = xml.selectnodes (path)

Less efficient but simpler would be:
set node = xml.selectnodes ("//escanoffer")

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 1 '06 #6
Something is strange here. Some htmlencoding is occurring somewhere. Is
this
really what it looks like?
YES

What about when you View Source?
THAT IS WHAT I SENT YOU

Do the &lt; become < ?
NO

Could this be a problem on the host side??

I thought this could be a firewall issue. I ran the script from a box
sitting outside, same result.

My entire script is below. User name & password changed for security.

~_~_~_~Begin Script~_~_~_~
<%@ Language=VBScri pt %>
<%Response.Buff er=true%>
<%
const SoapServer =
"https://webapps.agbr.co m/AGLinkiDataHost er/AGLinkiDataHost .asmx"

set xmldom = server.CreateOb ject("Microsoft .XMLDOM")
set xmlhttp = server.CreateOb ject("Microsoft .XMLHTTP")
xmlhttp.open "POST", SoapServer, false
xmlhttp.setRequ estHeader "Man" , POST & "
/AGLinkiDataHost er/AGLinkiDataHost .asmx HTTP/1.1"
xmlhttp.setRequ estHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequ estHeader "Content-Length", Len(SoapTest)
xmlhttp.setRequ estHeader
"SOAPAction","h ttp://tempuri.org/AGLinkiDataHost er/AGLinkiDataHost/RetrievePromoti onalOpportuniti esList"

xmlhttp.send(So apTest)

if xmlhttp.Status = 200 then '405 means error, 200 means ok. You know
why.

Set xmldom = xmlhttp.respons eXML

Dim xml
Set xml = Server.CreateOb ject("Microsoft .XMLDOM")
'Set xml = Server.CreateOb ject("Msxml2.DO MDocument.3.0")
xml.setProperty "SelectionLangu age", "XPath"
xml.async = False
xml.loadXML xmldom.xml

dim nodes, node, attrs, attr, i
set nodes = nothing
path="/RetrievePromoti onalOpportuniti esListResponse" & _
"/RetrievePromoti onalOpportuniti esListResult/deals" & _
"/escanoffers/escanoffer"
'set node = xml.selectnodes (path)
set node = xml.selectnodes ("//escanoffer")
'set node =
xmldom.selectno des("/RetrievePromoti onalOpportuniti esListResponse/RetrievePromoti onalOpportuniti esListResult/deals/escanoffers")

if not nodes is nothing then
for i = 0 to nodes.length - 1
set attrs = node.attributes
for x = 0 to attrs.length-1
set attr=attrs.item (x)
response.write "nodename:" & attr.nodename & "<br>"
response.write "nodevalue: " & attr.nodevalue & "<br>"
next
set node = nodes.nextnode
next
end if

'Set xml = Nothing
Response.write( xml.xml)
Else
Response.Write( "Didn't Work<BR>")
Response.Write( "status="&xmlht tp.status)
Response.write( "<BR>"&xmlhttp. statusText)
Response.Write( "<BR>"&Request. ServerVariables ("ALL_HTTP") )
End if
set xmlhttp = nothing
set xmldom = nothing
function SoapTest()
SoapTest = SoapTest & "<soap:Enve lope
xmlns:xsi=""htt p://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""htt p://www.w3.org/2001/XMLSchema""
xmlns:soap=""ht tp://schemas.xmlsoap .org/soap/envelope/"">"
SoapTest = SoapTest & " <soap:Body>"
SoapTest = SoapTest & " <RetrievePromot ionalOpportunit iesList
xmlns=""http://tempuri.org/AGLinkiDataHost er/AGLinkiDataHost "">"
SoapTest = SoapTest & " <Username>ROUSE CORP</Username>"
SoapTest = SoapTest & " <Password>agR18 !</Password>"
SoapTest = SoapTest & " </RetrievePromoti onalOpportuniti esList>"
SoapTest = SoapTest & " </soap:Body>"
SoapTest = SoapTest & "</soap:Envelope>"
end function
%>
~_~_~_~End Script~_~_~_~

Feb 1 '06 #7
lr*****@gmail.c om wrote:
Something is strange here. Some htmlencoding is occurring somewhere.
Is this
really what it looks like?
YES

What about when you View Source?
THAT IS WHAT I SENT YOU

Do the &lt; become < ?
NO

Could this be a problem on the host side??

I thought this could be a firewall issue. I ran the script from a box
sitting outside, same result.

My entire script is below. User name & password changed for security.
Set xmldom = xmlhttp.respons eXML

Why not use xmldom? What is the point in creating another object?
Dim xml <snip> 'set node = xml.selectnodes (path)
set node = xml.selectnodes ("//escanoffer")
'set node =

xmldom.selectno des("/RetrievePromoti onalOpportuniti esListResponse/RetrievePr
omotionalOpport unitiesListResu lt/deals/escanoffers")

oops - typo on my part here: "node" should be "nodes" in the previous
statement.

Other than that, I really don't know what is going on.

Does the encoding occur if you do this?

response.conten ttype="text/xml"
xmldom.save Response
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 1 '06 #8
Now, since I added

response.conten ttype="text/xml"
xmldom.save Response

the XML displays correctly in IE, but the view source still returns the
same stuff ...&lt;deals&gt ;&lt;escanoffer s&gt;&lt;...a nd the script
does not dispaly any node names or values.

Feb 1 '06 #9
lr*****@gmail.c om wrote:
Now, since I added

response.conten ttype="text/xml"
xmldom.save Response

the XML displays correctly in IE, but the view source still returns
the same stuff ...&lt;deals&gt ;&lt;escanoffer s&gt;&lt;...a nd the
script does not dispaly any node names or values.


Since it displays correctly in the browser window, could you copy it from
there, cut out the majority of the child nodes and post it here?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Feb 2 '06 #10

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

Similar topics

0
2768
by: System | last post by:
Hello All, Redhat 9.0 Mysql 3.23.56 ==> Running I want to upgarde to 4.0.13 but this is the error it says: # rpm -Uvh MySQL-server-4.0.13-0.i386.rpm warning: MySQL-server-4.0.13-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5 error: Failed dependencies: libmysqlclient.so.10 is needed by (installed) mod_auth_mysql-1.11-12
8
1607
by: Stephen | last post by:
I am trying to add some code to below to include a datatable and fill the datatable. The reason for doing this is so as I can check to see whether there are any rows returned by the stored procedure. If there are no records returned then this would give me an indicator and I can re-direct the page somewhere more appropriate. Well this is the theory. I have never used datatables before and am not sure how to implemenet what I want so I was...
13
1747
by: Joe Feldman | last post by:
This position is located in the South Bay Area in Northern California. If you are interested please send me your resume in a word .doc so that I can review it. If this does not look like a match, we have over 100 other open positions. Senior Member of Technical Staff/ Principal Engineer- Protocols Infrastructure
0
1798
by: Cindy B | last post by:
Please send your resume and position to Cindy@AtlanticResource.com! I CAN NOT accept candidates that ARE OUTSIDE OF THE US! NO PHONE CALLS PLEASE! Email your resume to me! Position:SQL SERVER/PEOPLESOFT DBA Date: 03/07/05 Location: Richmond, VA Duration: 5 month conract to hire Salary: 65,000-80,000K Contract to Hire 5 months
3
2267
by: Wade | last post by:
I would like to install the .Net 1.1 framework on a Web Server running W2K to be able to run ASP.NET files, but I'm not sure where to find the files I need for the .Net framework. I have ".NET Framework 1.1 Service Pack 1" (NDP1.1sp1-KB867460-X86.exe) and "ASP.NET Security Update for .NET Framework 1.1 SP1" (NDP1.1sp1-KB886903-X86.exe). The SP1 will not install unless 1.1 is already installed (I thought that SP1 was the whole 1.1...
17
2343
by: dingoatemydonut | last post by:
The C99 standard states: "In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no needed side effects are produced (including any caused by calling a function or accessing a volatile object)." Does that mean that in the following code, *p does not have to be evaluated since its side...
5
1708
by: Steve | last post by:
Hi, I am sitting down to design our next set of internal apps. I would like to approach this in a way that would allow me to break logical parts of the application that handle specific tasks into modules. For example, assuming we have 4 main tasks to accomplish: - Printing - Editing - Viewing - Inventory Management
0
1484
by: ultradiv | last post by:
I have a VB.NET application partly built that produces an xml output (just a file at present) I have a .NET webserver and SQLserver 2000 I need to be able to send the xml to the webserver/database (some crunching is needed before the data is stored) The database (stored proc.) will reply with several small pieces of data which need to be sent back to the client app. I am thinking that all of this could be accomplished in one call to a...
28
1938
by: Ian Davies | last post by:
Hello I would appreciate some help from someone who has knowledge of working with css, php javascript and how they interact. Ive been working on a task for the last few days and have started to hit a brick wall. I need general advice on whether I m tackling the problem the correct way and some solutions for my current problems Ive posted my project below where ive detailed the current problems im having...
37
2398
by: C_guy | last post by:
Does anyone know of a (hopefully free) tool that can traverse a project and determine which "#include"s are not needed or needed in every .C file? This would be helpful in removing header inclusions that are redundant and/or unnecessary. Thanks!
0
8609
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
9166
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
9030
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...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7737
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
5861
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
4371
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
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
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.