Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading XML file into a RecordSet using ASP????

Status
Not open for further replies.

notrut

Programmer
Feb 6, 2002
87
CA
Hi,

I was just wondering if it is possible to load a XML file into a Recordset using ASP????

Any help would be greatly appreciated!!
 
yes, you should use MSXML parser to read XML.

Ion Filipski
1c.bmp
 
Sounds good to me, but I'm not sure how to do that since I'm pretty new to XML.

Right now, I'm loading the XML file into an array by using the following code:

Set xfdoc = server.CreateObject("MSXML2.FreeThreadedDOMDocument")
xfdoc.async = False
xfdoc.Load (Server.MapPath("BUFiles.xml"))
Set xfdocelem = xfdoc.documentElement

If xfdocelem Is Nothing Then
Response.Write "ERROR: Nothing in file:" & err.number & ": " & err.description
ELSE

Redim astrArrayNode(3, xfdocelem.ChildNodes.length)

If xfdocelem.ChildNodes.length > 1 Then
For Each xfdocnode In xfdocelem.ChildNodes
intIndexI = intIndexI + 1
If Len(Trim(xfdocnode.nodename)) > 0 Then
astrArrayNode(0,intIndexI) = xfdocnode.nodename 'Name of File
astrArrayNode(1,intIndexI) = xfdocnode.getAttribute("OldURL") 'Old URL
astrArrayNode(2,intIndexI) = xfdocnode.getAttribute("NewURL") 'New URL
End If
Next
end if
End If

Is there an easy way to modify this so it will load into a recordset??

 
I think this code is enough easy to use and to understand. Only you need now, is to know how to use ADO recordet.

Ion Filipski
1c.bmp
 
But isn't there a way to load an xml file directly into a recordset? something similar to

Code:
set oRs = server.createobject("adodb.recordset")
fXML = server.mappath("people.xml")
oRs.open fXML, adPersistXML

or something? cos this is doing my head in. All I want to do is use a dead simple xml lookup file (<item><value>1</value><name>bob</name></item> - that kinda thing) and query it to get a particular <name>.text given a particular <value>.text value.

I know all about the
Code:
load
ing and
Code:
selectNodes
stuff using an XML Dom Object, but if anyone can help with either loading the xml into a recordset, or query the XML dom in this fashion I'd muchos appreciate it...


--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
OK - update. I've found that this kinda works;

Code:
oRs.Open sFilePath, &quot;Provider=MSPersist;&quot;, adOpenForwardOnly, adLockReadOnly, adCmdFile

but I get the error

Code:
Source XML is incomplete or invalid

The source xml is just fine n dandy, but is there a particular style that ADO requires for this to work?

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top