Results 1 to 15 of 15

Thread: (ASP & XML) Parsing through an XML file to extract data. **Resolved**

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    (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.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    Cander: got anything for using SAXXML (4.0) and loading all that into memory with the global.asa?

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    mmm no. A search on google didnt turn up anything relevant.

    Try looking around at www.vbxml.com
    perhaps you can find something there.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    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.

  6. #6

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  7. #7

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    case sensitivity is a BIG gotcha in xml. gotta watch out for that.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  10. #10

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  11. #11

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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:
    1. Set objList = objXML.getElementsByTagName("*")
    2.  
    3. For intCount = 0 To (objList.length -1)
    4.      Response.write "<b>" & objList.item(intCount).nodeName & "</b><br>"
    5.      Response.write objList.item(intCount).text & " " & intCount & "<br><br>"
    6. 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.

  12. #12
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  13. #13

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  14. #14

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    getting closer?

    ok I tried to do an:
    VB Code:
    1. Set objList = objXML.getElementsByTagName("*")
    2.  
    3. For intCount = 0 To (objList.length -1)
    4.    If objList.item(intCount).hasChildNodes Then
    5.       'do something
    6.   Else
    7.       'write the value and the compunded name
    8.   End If
    9. 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.

  15. #15

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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
  •  



Click Here to Expand Forum to Full Width