PDA

Click to See Complete Forum and Search --> : Displaying the XML data in a Listview Control


getprashanth
Sep 23rd, 2002, 10:03 PM
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

cim3
Sep 24th, 2002, 04:18 AM
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)