Results 1 to 5 of 5

Thread: Reading from an awkward file...Thanks

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Reading from an awkward file...Thanks

    Hello,

    Any help is appreciated,

    I wish to read from a data file called persist.data and then read the ENTIRE file into one variable. Is this possible?
    The file contents will also be this only with different numbers.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    	<server>
    		<stats>
    			<total>
    				559
    			</total>
    			<error>
    				16
    			</error>
    			<html>
    				197
    			</html>
    			<image>
    				362
    			</image>
    			<notmodified>
    				149
    			</notmodified>
    			<bytes>
    				3043332
    			</bytes>
    			<uptime>
    				5154
    			</uptime>
    			<since>
    				Wed, 15 Jun 2005 14:05:31 GMT
    			</since>
    		</stats>
    		<host>
    			<id>
    				1
    			</id>
    			<stats>
    				<total>
    					559
    				</total>
    				<error>
    					16
    				</error>
    				<html>
    					197
    				</html>
    				<image>
    					362
    				</image>
    				<notmodified>
    					149
    				</notmodified>
    				<bytes>
    					3043332
    				</bytes>
    				<uptime>
    					5154
    				</uptime>
    				<since>
    					Wed, 15 Jun 2005 14:05:31 GMT
    				</since>
    			</stats>
    		</host>
    	</server>
    </root>
    Persist.data

    Could all of this data fit into one variable?
    If not, how would I got about split it into an array using the Input command.

    Regards,

    Jord

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Re: Reading from an awkward file...Thanks

    Quote Originally Posted by MartinLiss
    Do you know anything about the XML DOM?
    Afraid not, all I know is that it is a user defined set of tags.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Reading from an awkward file...Thanks

    Then what you want to do is to download MSXML4 from Microsoft and install it. You may already have MSXML2 or 3 on your PC and they will work but 4 is better. Then using commands like selectNodes you will be able to get at the data you need. There are a lot of examples in this forum and the XML forum that should help you, and/or you can ask questions once you get started.

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Reading from an awkward file...Thanks

    to read it into one variable
    VB Code:
    1. Dim FileLen As Integer
    2. Dim inVar As String
    3. Open "C:\Persist.data" For Binary As #1
    4. FileLen = LOF(1)
    5. inVar = String(FileLen, 0)
    6. Get #1, , inVar
    7. Close #1
    8. Debug.Print inVar

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