|
-
Aug 14th, 2002, 12:56 PM
#1
Thread Starter
Frenzied Member
(ASP & XML) Parsing through an XML file to extract data. **Resolved**
Soon I will need to extract data from an XML file. These files will be in a directory on my server. Does anyone have any good tutorials on this? I've never dealt with XML before.
Thanks
Michael
Last edited by msimmons; Aug 15th, 2002 at 03:29 PM.
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 14th, 2002, 01:03 PM
#2
-
Aug 14th, 2002, 02:24 PM
#3
Addicted Member
Cander: got anything for using SAXXML (4.0) and loading all that into memory with the global.asa?
-
Aug 14th, 2002, 02:31 PM
#4
mmm no. A search on google didnt turn up anything relevant.
Try looking around at www.vbxml.com
perhaps you can find something there.
-
Aug 14th, 2002, 02:45 PM
#5
Thread Starter
Frenzied Member
Almost Forgot...
Thanks for that link. I also found this one to be helpful:
http://www.15seconds.com/issue/990527.htm
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 14th, 2002, 04:19 PM
#6
Thread Starter
Frenzied Member
I am trying to do the example on the link I posted and failing miserabley... (i suck at spelling too) Is it me or the example that is not working?
Code:
<%
Option Explicit
Dim objXML
Dim objList
Dim intCount
Dim strDate
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objList = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.Load (Server.MapPath("mostRecentScriptingNews.xml"))
Set objList = objXML.getElementsByTagName("*")
For intCount = 0 To (objList.length -1)
If objList.item(intCount).nodeName = "pubDate" Then
strDate = objList.item(intCount).text
Exit For
End If
Next
response.write ". " & strDate & " ."
%>
thanks in advance,
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 14th, 2002, 04:56 PM
#7
Thread Starter
Frenzied Member
It was me ... aparently <Name> dosent match </name>
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 08:57 AM
#8
case sensitivity is a BIG gotcha in xml. gotta watch out for that.
-
Aug 15th, 2002, 09:25 AM
#9
Thread Starter
Frenzied Member
Yea, I had read that when I first started looking into this project about a yr ago (yes, I am very backlogged ). I had to create a sample xml file from a hard copy because after a year I can no longer find my digital copy. I think I had 3 typos in the whole thing (not bad for 3 pages though )
Thanks
Michael
ps Know any good references for asp/xml DOM?
Thanks again
MS
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 09:35 AM
#10
Thread Starter
Frenzied Member
Found a good one:
http://www.devguru.com/Technologies/...dom_index.html
but... I am trying to get the name of each node what is the ."thisthing" for that?
thanks
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 10:22 AM
#11
Thread Starter
Frenzied Member
OK, here's my problem.
I want to dynamicly assign the name and the value in a for loop... I have this and it will work but I want better 
VB Code:
Set objList = objXML.getElementsByTagName("*")
For intCount = 0 To (objList.length -1)
Response.write "<b>" & objList.item(intCount).nodeName & "</b><br>"
Response.write objList.item(intCount).text & " " & intCount & "<br><br>"
Next
But if I have this in the XML File:
Code:
<Guests>
<Guest>
<NameInfo>
<NameFirst>Daffy</NameFirst>
<NameLast>Duck</NameLast>
I am only getting "NameFirst" when exicuting the nodeName... I may have another "NameFirst" (like under billing or something) so I want to get the names of the parent nodes as well or something to that effect...
Any Ideas?
Thanks
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 10:26 AM
#12
you might want to look into using XSL to parse the XML into html. You can do that client AND server side which is cool. Go herre for more info
http://www.xmlfiles.com/xsl/
xsl provides looping and if statements so you get a lot flexability
-
Aug 15th, 2002, 10:52 AM
#13
Thread Starter
Frenzied Member
The thing is that this won't be displayed in the browser and if so it is only on the sever so no one will see it (unless they are logged in looking at the server.
What I am doing is taking information form the XML file and 1) storing parts in the database 2) emailing parts various places. So I am trying to get the data from the XML to ASP variables.
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 11:14 AM
#14
Thread Starter
Frenzied Member
getting closer?
ok I tried to do an:
VB Code:
Set objList = objXML.getElementsByTagName("*")
For intCount = 0 To (objList.length -1)
If objList.item(intCount).hasChildNodes Then
'do something
Else
'write the value and the compunded name
End If
Next
In theroy I thought it would work but fo some reason it sees:
<NameFirst>Daffy</NameFirst>
as having a child... what is dosen't see as having a child though is:
<Membership MemberType = "Mileage Plus" MemberNumber = "0033445689" MemberLevel = "Premier"/>
hmmm... any suggestions ideas or insight?
Thanks
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Aug 15th, 2002, 03:29 PM
#15
Thread Starter
Frenzied Member
Ok. I have it figured and working 
what I did was strored the node names in an array as I went along and checked against the next node's parent to see if I incremented the array or went backwardds in the array ... confusing at first but worked like a charm 
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|