troubleshooting XML help please- a formatting problem?

daniella

Member
Joined
Apr 13, 2009
Messages
6
Location
england
Programming Experience
Beginner
hello! i'm having a minute, but massive in its own special way, problem with the appearance of my program? a brief outline of my program just in case it helps:

- VB.Net/windows XP (on virtual box as i'm on leopard OS x but that's unimportant just explains the weird screen caps!)
- a quiz type system, it's incomplete atm
- loading the XML data into this user interface..with these ANNOYING squares

HERE IS THE PROBLEM:


picture6lpl.png


the weird hallow squares after every string of text? how do i get rid of those? i'm posting here, even though it's a tiny problem, because i have NO idea what to google for. literally any help would be appreciated pleasepleaseplease- even just telling me the google keywords. i can't think of what to write other than 'xml string square' or something which comes up with complete rubbish. here's a break down of my project incase you can detect something i can't (i've only been doing this for a year, this is for my final project)

anyway, here's the XML document i set up:

picture7osc.png


here's the code (so you can analyse it to see if there's some flaw in that HENCE the weird squares

VB.NET:
    Private Sub THEYTEST_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'this procedure responds to the loading of the page
        'this creates an XmlDocument object from the XML file (initiates all XML related things)
        Dim doc As New System.Xml.XmlDocument
        doc.Load("C:\Documents and Settings\Administrator\My Documents\PROJECTFILES\theirquestion.xml")
        'this creates an xmlnodelist from the <question> elements and the nested (i.e: question, correct_answer) elements
        Dim nodes As System.Xml.XmlNodeList
        nodes = doc.SelectNodes("qs_table/q") 'references the table in the xml document
        Dim counter = 0 'initiates counter at zero
        'NOTING FOR THE CODE BELOW
        'selecting the nu string to display shows the number of the questions
        'the counter ensures that every <q> node in the document is output
        'the question element displays the full question (a string var)
        'listboxquestion is the listbox at the top of the userinterface that displays: x. questiontext 

        Do Until counter = nodes.Count 'ensures the entirity of the document is read until there are no nodes left (at the end)
            listboxquestion.Items.Add(nodes.Item(counter) _
                .SelectSingleNode("nu").InnerText & vbTab _
                & nodes.Item(counter) _
                .SelectSingleNode("question").InnerText & vbCrLf)
            counter += 1
        Loop

        ''*****PROCEDURE: ASSIGNING VALUES TO EACH RADIO BUTTON FROM XML DATASHEET*****

        ''**VAR LIST:
        'the following variables are used in determining a random number in the assignment of values to the radio buttons
        'a regarding 1st question, b regarding 2nd question, etc etc. 
        Dim a_number As Integer
        Dim b_number As Integer
        Dim c_number As Integer
        Dim d_number As Integer
        Dim e_number As Integer
        Dim f_number As Integer
        Dim g_number As Integer
        Dim h_number As Integer

        Randomize()
        ' this procedure mixes up whether a or b will be the correct answer.
        'the first time the question is shown, A may be the correct answer but the second time B may be
        '(nodes.Item(number) where number refers to the metaphorical pointer position in the XML document.
        'VARIABLE NOTES: when generating number the a,b,c_number is used purely to generate the outcome of the IFTHENELSE statement
        '****ASSIGNING VALUES FOR QUESTION BOX NUMBER 1*****
        a_number = Int((2 - 1 + 1) * Rnd() + 1) 'this generates a random number: either 1 or 2.
        If a_number = 1 Then 'if the number randomly selected is one then A is the correct answer, B is incorrect.
            Q1A.Text = (nodes.Item(0) _
                .SelectSingleNode("correct_answer").InnerText & vbTab)
            Q1B.Text = (nodes.Item(0) _
                .SelectSingleNode("incorrect_answer").InnerText & vbTab)
            Q1C.Text = (nodes.Item(0) _
                       .SelectSingleNode("incorrectanswer2").InnerText & vbTab)
        Else 'if the number randomly selected is NOT 1 (i.e: 2) then A is the incorrect answer, and B is correct.
            Q1A.Text = (nodes.Item(0) _
                .SelectSingleNode("incorrect_answer2").InnerText & vbTab)
            Q1B.Text = (nodes.Item(0) _
                .SelectSingleNode("correct_answer").InnerText & vbTab)
            Q1C.Text = (nodes.Item(0) _
                    .SelectSingleNode("incorrect_answer").InnerText & vbTab)
        End If
'** obviously the question thing continues and continues but it's all pretty identical and there's no point in spamming you with it

any help is really appreciated, thankyou very much for reading :) xoxo
 
I had a look at your post, and I must say I'm not able to reproduce the issue you describe from the information you have provided. That said, perhaps the problem with your system is the "InnerText & vbTab" where the Tab could produce the square chars? Why do you add them by the way?

with these ANNOYING squares
Another thing, when you say this I think about the annoying squares in your post tomorrow when ImageShack is gone. Attach images to the post instead.
 
that's a very good point, i added them because the tutorial i was given (in a textbook of mine) loaded 2 elements into the listbox, whereas i'm listing one, and i'm now thinking that vbtab was a method of separating the two elements? therefore they COULD be responsible for the square characters- ahh ideaaa!

thankyou veryyy much for your help! :)

p.s: sorry, i've never posted to a forum except livejournal before so i'm new to this, i attached the pictures to the post!
 
Back
Top