•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 370,597 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,026 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 3723 | Replies: 1
![]() |
•
•
Join Date: Dec 2005
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Hello all,
I hope that this is in the right place - sorry if it is not.
I have an asp script (which is contained in a .vbs file) that takes info from an XML page and inserts it into a database. I was trying to get the the script to preform a test to see if the xml script contains a certain element - if it does, then enter it into a database.
Here is the code :
And here is the error message I am getting :
any ideas as to what might be the problem here? I really appreciate any input as I have a horrible deadline for this! :o
Thanks folks
I hope that this is in the right place - sorry if it is not.
I have an asp script (which is contained in a .vbs file) that takes info from an XML page and inserts it into a database. I was trying to get the the script to preform a test to see if the xml script contains a certain element - if it does, then enter it into a database.
Here is the code :
Dim XMLDom
Dim ItemID
Dim DbConn
Dim SQLString
Dim ANArticleNode
Dim ANArticleNode2
Dim CollectionOfArticleNodes
Dim CollectionOfArticleNodes2
Dim cst
Set XMLDom = CreateObject("MSXML2.DomDocument.4.0")
XMLDom.async = False
XMLDom.setProperty "ServerHTTPRequest", True
Set DbConn = Createobject("adodb.connection")
DbConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=test1.mdb"
'-- Load the XML data from your live URL
XMLDom.Load("http://feeds.directnews.org.uk/?ad96035d-f9fe-4a3f-a5b2-ad546b2ed850")
'-- Create a reference to a collection of all Article Tags within the downloaded XML Document
Set CollectionOfArticleNodes = XMLDom.SelectNodes("InfoStreamResults/Article/Categories/Category")
'-- Iterate the collection of Article Tags
For Each ANArticleNode in CollectionOfArticleNodes
ItemID = ANArticleNode.SelectSingleNode("@ID").text
if ItemID = "430009735" then
set CollectionOfArticleNodes2 = XMLDom.SelectNodes("InfoStreamResults/Article")
Heading = ANArticleNode2.SelectSingleNode("Heading").text
'-- Insert the item into the local database
SQLString = "INSERT INTO test (Heading) " _
& "VALUES('" & EncodeIt(Heading) & "');"
DbConn.Execute(SQLString)
End If
Next
'-- Handles quotations in text
Function EncodeIt(TextString)
TextString = Replace(CStr(TextString), "''", "'")
TextString = Replace(TextString, "'", "''")
EncodeIt = TextString
End FunctionAnd here is the error message I am getting :
Object required: "
any ideas as to what might be the problem here? I really appreciate any input as I have a horrible deadline for this! :o
Thanks folks
•
•
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation:
Rep Power: 4
Solved Threads: 7
Your problem is caused because you are trying to reference a node from inside another node (does that make sense?). Anyway, try the modified script below:
<%
Dim XMLDom
Dim ItemID
Dim DbConn
Dim SQLString
Dim ANArticleNode
Dim ANArticleNode2
Dim CollectionOfArticleNodes
Dim CollectionOfArticleNodes2
Dim cst
Set XMLDom = CreateObject("MSXML2.DomDocument.4.0")
XMLDom.async = False
XMLDom.setProperty "ServerHTTPRequest", True
Set DbConn = Createobject("adodb.connection")
DbConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=test1.mdb"
'-- Load the XML data from your live URL
XMLDom.Load("http://feeds.directnews.org.uk/?ad96035d-f9fe-4a3f-a5b2-ad546b2ed850")
'-- Create a reference to a collection of all Article Tags within the downloaded XML Document
Set CollectionOfArticleNodes = XMLDom.SelectNodes("InfoStreamResults/Article")
'-- Iterate the collection of Article Tags
For Each ANArticleNode in CollectionOfArticleNodes
'-- Now create a reference to the category tag
Set CollectionOfArticleNodes2 = ANArticleNode.SelectNodes("Categories/Category")
'-- And iterate through the nodes to test for a match
For Each ANArticleNode2 in CollectionOfArticleNodes2
ItemID = ANArticleNode2.SelectSingleNode("@ID").text
if ItemID = "430009735" then
'-- Retrieve the value of the heading node from the current article
Heading = ANArticleNode.SelectSingleNode("Heading").text
'-- Insert the item into the local database
SQLString = "INSERT INTO test (Heading) " _
& "VALUES('" & EncodeIt(Heading) & "');"
DbConn.Execute(SQLString)
end if
Next '-- check the next category ID
Next '-- move to the next article
'-- Handles quotations in text
Function EncodeIt(TextString)
TextString = Replace(CStr(TextString), "''", "'")
TextString = Replace(TextString, "'", "''")
EncodeIt = TextString
End Function
%> If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.
Lafinboy Productions
:: Website Design :: Website Development ::
Lafinboy Productions
:: Website Design :: Website Development ::
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
- How to Parse XML in ASP? (ASP)
- Help needed in simple app while using XML,XSL (XML, XSLT and XPATH)
- Parse XML from ASP!!! (ASP)
- Error while running ASP.NET (ASP.NET)
- ASP.NET <--> XML <--> VB6.0 (ASP.NET)
- Error message when running ASP email script (ASP)
Other Threads in the ASP Forum
- Previous Thread: problem running asp scripts in windows xp pro
- Next Thread: final year proj


Linear Mode