Results 1 to 2 of 2

Thread: Displaying the XML data in a Listview Control

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Kuala lumpur
    Posts
    8

    Thumbs up Displaying the XML data in a Listview Control

    Hi,
    I am involved in making an interface for a bluetooth project, I have to extract the data from a XML file by parsing it and put it in a list view control. I am successful in extracting the data, but I find some unwanted characters before and after the actual data, I have to display.
    The point to be noted is that when I display the same on a form/panel using DrawString(), I find the data without any unwanted characters. The problem is arising only when I display it in a ListView control. I am pasting the code I have written, Can anyone suggest me the way by which I can eliminate the unwanted characters and display the actual data... All suggestions are welcome...


    Prashanth


    CODE (IN VB.Net):
    In Button_Click()



    Dim g As Graphics = CreateGraphics()
    Dim f As Font = DefaultFont()
    Dim b As Brush = New SolidBrush(Color.Blue)

    Dim document As XmlDocument = New XmlDocument()
    document.Load("XMLFile1.xml")

    Dim reader As XmlNodeReader = New XmlNodeReader(document)



    While reader.Read
    Select Case reader.NodeType

    Case XmlNodeType.Element

    Select Case reader.Name
    Case "Inside"
    reader.Read()
    ListView2.Items.Add(CStr(reader.Value), 0)
    ListView2.Height = ListView2.Height + ListView2.Font.Height * 6 / 4
    End Select

    End Select
    End While
    MY project queries

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    What characters are you getting??
    Number of suggestions
    1.ctype(reader.Value,string) instead of cstr - which is vb6

    2.Put in a function to strip the characters
    ctype(RemoveChr(reader.Value),string)
    Wind and waves resolves all problems.

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