< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
I have made a small program in which there is a web service which reads an xml data and returns a dataset of it. At the same time I made a pocket pc application that consumes the web service and displays the values of the dataset on a text box of pocket pc. but problem is when it displays the data on text box the data have some junk character. I am a beginner of using this please help me this is code of web service:-
<WebMethod()> Public Function BuildDataSet() As DataSet
Dim DataSetObj As New DataSet
Try
DataSetObj.ReadXml("C:\Inetpub\wwwroot\readxmldata\bin\dataHCS.xml")
BuildDataSet = DataSetObj
Catch ex As Exception
Throw ex
End Try
Return DataSetObj
End Function
This is the code of pocket pc which consumes this web service through add reference
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objData As localhost.Service1 = New localhost.Service1
Try
Dim I As Integer
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
'For I = 0 To objData.BuildDataSet.Tables(0).Rows.Count - 1
TextBox1.Text = TextBox1.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("NHS") & vbCrLf
TextBox2.Text = TextBox2.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("Name")& vbCrLf
TextBox3.Text = TextBox3.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("Sex") & vbCrLf
TextBox4.Text = TextBox4.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("DOB") & vbCrLf
TextBox5.Text = TextBox5.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("BloodGroup") & vbCrLf
TextBox6.Text = TextBox6.Text & _
objData.BuildDataSet.Tables(0).Rows(I).Item("Address") & vbCrLf
' Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Please help in this problem
Regards,
rage

Junk characters when display in pocket pc through web service
mcclurgj
You see the junk characters because in your XML file (dataHCS.xml) there are carriage return and line feed characters at the end of each item. These whitespaces are retained according to the XML standards and are returned together with the data when the web service is called. To remove the junk characters, you can use the String.Trim() method. Your app will work fine if you replace the above codes with the following:
TextBox1.Text = TextBox1.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("NHS"), String).Trim() & ""TextBox2.Text = TextBox2.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("Name"), String).Trim() & ""TextBox3.Text = TextBox3.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("Sex"), String).Trim() & ""TextBox4.Text = TextBox4.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("DOB"), String).Trim() & ""TextBox5.Text = TextBox5.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("BloodGroup"), String).Trim() & ""TextBox6.Text = TextBox6.Text & _
CType(objData.BuildDataSet.Tables(0).Rows(1).Item("Address"), String).Trim() & ""Cheers,
Anthony Wong [MSFT]
Jeffrey De Pretre
I suspect there might be something wrong with the encoding you are using.
Please post the xml file and we will take a look into this.
Thanks.
double_detente
Could you take a snapshot of your device showing the junk characters displayed in the text box and send it to Anthony.Wong@microsoft.com That would help me diagnose the issue.
Cheers,
Anthony Wong [MSFT]
ms44cn
hi mark
thanks for your intrust in helping.... the xml file is this:-
< xml version="1.0" encoding="utf-8" >
<DataSet>
<DataPatient>
<NHS>1
</NHS>
<Name>a
</Name>
<Sex>m
</Sex>
<DOB>455665
</DOB>
<BloodGroup>+b
</BloodGroup>
<Address>werwer
</Address>
</DataPatient>
<DataPatient>
<NHS>2
</NHS>
<Name>b
</Name>
<Sex>f
</Sex>
<DOB>23433
</DOB>
<BloodGroup>+r
</BloodGroup>
<Address>3243ewrwer
</Address>
</DataPatient>
</DataSet>
regards
rage