Wrox Programmer Forums
|
BOOK: Visual Basic 2010 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2010 Programmer's Reference by Rod Stephens; ISBN: 9780470499832
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2010 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2012, 11:47 AM
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default More info on XMLTextWriter

Is there a good detailed source on the XMLTextWriter object? I need to write many large-ish XML files to test an application. I can handle a lot of it, but details on using multiple namespaces is hard to find. It seems XMLTextWriter is the way to go since the files are large - they contain base64 data as well as other string elements. Does WROX have anything that covers this in detail?
Thanks for any help.
 
Old June 13th, 2012, 07:06 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I don't have any really great source for this, although I'm sure there are books out there. My book Visual Basic .NET and XML covers this to some extent.

The bad news is that this book is pretty old (published in 2002). The good news is that most of what it says about XmlTextWriter and XmlTextReader is probably still valid. The better news is that you can get a used copy from Amazon for under $5 including shipping! For that kind of money, you may want to take a look at it.

Or you can look online. Microsoft has the class documented, just not in a nice book format.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 
Old June 21st, 2012, 02:27 PM
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank you for the response

Thanks for the response. The Microsoft documentation is pretty thin - I end up doing a lot of translating from Javascript to VB. I have not found a good source that treats advanced examples, like multiple namespaces and more than two levels. I have found some examples in VBNET, but even those can make you wonder why.
 
Old June 26th, 2012, 11:39 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I know what you mean about the Microsoft documentation. All of the information is out there but it can be hard to put together in a useful way.

I would try to get a book, either my old one or a newer one. That may save you a lot of time. (Sorry I don't know of a good online resource.)
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 
Old June 28th, 2012, 01:28 PM
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks again

Explaining my 'problem' may add some perspective. I am a (experienced) tester who can program. One of the principal issues testers have is creating good test data. All the examples you see assume there is some GUI already there you can type a few records into, and you are done. More common is the need to generate hundreds of records in some format that was just designed as part of development, and do it right now, since it is not even in the schedule.
I have never seen a book address this directly or as its principal purpose. Certainly testing books do not. I have written programs in VB expressly to create data I can use to test some system, which means I have often had to delve into the 'back of the book' chapters to find some trick or method to do the one thing I really need. Addressing these issues in one collection would be really useful.
Visual Basic for Testers
 
Old June 28th, 2012, 01:40 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

You're right that most books, even testing books, don't cover this. They assume that you can use random generators of some sort to create your data. I think they also assume that the data needed by a particular application will be so application-specific that it would be hard to write about it in a specific way.

For example, if you have a mapping application, you might need to generate random points on an electric power network. If you don't have a very similar application, then that would be useless.

Sometimes there are also issues with defining the type of randomness. You may need to pick values from a non-uniform distribution. It's pretty hard to write about that sort of thing, at least in specific, without knowing what kinds of distributions you want.

So books just don't bother. If you can't find a big enough common audience for a book, the publishers won't print it.

There are some places on the net where you can find some random data that may help. For example, it's easy to create random strings of letters and numbers in code but it's harder to generate reasonable random names for more realistic testing of those fields. If you search, you can find some random name generators that do a reasonable job.

I like the lorem ipsum generator at http://www.lipsum.com/ for random text that looks sort of like writing. It's useful for testing typographic programs. For example, it lets you see what paragraph breaks will look like.

I've posted a few examples that generate random values of various kinds.

http://www.vb-helper.com/howto_net_random_colors.html
http://www.vb-helper.com/howto_net_random_records.html
http://www.vb-helper.com/howto_net_random_strings.html
http://www.vb-helper.com/howto_vba_p..._elements.html

If you enter "random site:vb-helper.com" in your favorite search engine, you may be able to find a few others.

If there are specific cases that you're having trouble with, let me know and I'll see if I can help.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 
Old June 28th, 2012, 02:00 PM
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not Random data

I should have explained the data is never random. It has names, countries, cities, dates within certain ranges. Think immigrants getting a government card to work in the USA. Images in base64 format. I generally use Access to store tables of data, then randomly select from the tables. Here is a small sample:

Code:
Function GetCountry() As String
Dim intUBound As Integer
Dim intLBound As Integer
Dim recnum As Integer
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset

Set conn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "tblCountry", conn, adOpenStatic
rst.MoveFirst
intLBound = rst.Fields("ID").Value
'MsgBox intLBound
rst.MoveLast
intUBound = rst.Fields("ID").Value
rst.MoveFirst
Randomize
recnum = ((intUBound - intLBound) * Rnd)
rst.Move recnum
GetCountry = rst.Fields("Country").Value
'cleanup
rst.Close
Set rst = Nothing
conn.Close
Set conn = Nothing

End Function
Here is a partial of writing a CSV file:
Code:
strFilename = CurrentProject.Path & "\" & strFilename
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtFile = fso.createtextfile(strFilename, True)


strTime = "T13:25:47"

Set rst = New ADODB.Recordset
rst.Open "Select * from tblFullRecordList", conn, adOpenDynamic, adLockOptimistic
'move to last record
rst.MoveLast

Set objFields = rst.Fields
'skip first field ID number
j = 1
For i = 1 To (objFields.Count - 1)
'write field names separated by commas
    txtFile.Write (objFields.Item(i).Name)
    If j < (objFields.Count - 1) Then txtFile.Write Chr(44)
    j = j + 1
Next i

'write a new line
txtFile.writeline
And this isn't even XML - I needed a CSV file in this case.
Of course you are correct about the audience and publishers. But 80% of software testing is still manual. And I have met very few testers who could code even this.
 
Old June 28th, 2012, 04:03 PM
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the biggest problem I am having right now is getting all these namespaces into the beginning of the XML message properly. Like I said, there are nine of them. I have tried several methods and they are just not doing want I want.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing XML file Using XmlTextWriter class tmadhavi XML 1 December 19th, 2007 09:20 AM
Serializing object into existing XmlTextWriter planoie .NET Framework 2.0 0 October 15th, 2007 09:54 AM
How to write this by xmlTextWriter yingwen XML 0 April 17th, 2007 09:40 PM
XML and the XMLTextWriter AgentSmith General .NET 1 May 10th, 2006 07:42 PM
Where would I get info on how to download info aidanc ASP.NET 1.x and 2.0 Application Design 1 September 29th, 2003 02:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.