用下面这段代码,虽然不报错但仍然有下面的异常字符出来.
尿亚硝酸盐--N{
"@xml:space": "preserve",
"#significant-whitespace": " "
}
Dim str4 As String = "http://10.27.1.1:8085/Service.asmx/Query?queryxml=<root><queryid>QueryReportDetail</queryid><args1>59711</args1></root>"
Dim hc As New HttpClient(str4)
Dim ret As String = hc.GetData()
Dim xo As XObject = XObject.Parse(HTMLDecode(ret))
If Typeof xo("NewDataSet")("ds") Is jarray Then '如果是数组 即 有多行结果用如下代码.
msgbox(0)
' With wb.AddTable("","Table1")
' .head.AddRow("项目名称","检查结果","范围","标志","单位") '主表的表头
For Each ds As JToken In xo("NewDataSet")("ds")
' .body.AddRow( CStr(ds("LISITEMNAME")), CStr(ds("RESULT")),CStr(ds("RANGE")),CStr(ds("FLAG")),CStr(ds("UNIT")) )
If Typeof ds("UNIT") Is jvalue Then
msgbox(00)
' output.show(ds("LISITEMNAME"),ds("RESULT"),ds("RANGE"),ds("FLAG"),ds("UNIT"))
Output.show(cstr(ds("LISITEMNAME")) & cstr(ds("RESULT")) & cstr(ds("RANGE")) & cstr(ds("FLAG")) & cstr(ds("UNIT")))
Else
msgbox(01)
Output.show(cstr(ds("LISITEMNAME")) & cstr(ds("RESULT")) & cstr(ds("RANGE")) & cstr(ds("FLAG")) & cstr(ds("UNIT").ToString)) '过滤掉中间的 <UNIT xml:space="preserve"> 解析时就报错
End If
Next
' End With
Else '如果不是数组,即呆有一行结果.
msgbox(1)
' With wb.AddTable("","Table1")
' .head.AddRow("项目名称","检查结果","范围","标志","单位") '主表的表头
' For Each ds As JToken In xo("NewDataSet")("ds")
' .body.AddRow( CStr(ds("LISITEMNAME")), CStr(ds("RESULT")),CStr(ds("RANGE")),CStr(ds("FLAG")),CStr(ds("UNIT")) )
If Typeof xo("NewDataSet")("ds")("UNIT") Is jvalue Then
msgbox(10)
output.Show(cstr(xo("NewDataSet")("ds")("LISITEMNAME")) & cstr(xo("NewDataSet")("ds")("RESULT")) & cstr(xo("NewDataSet")("ds")("RANGE")) & cstr(xo("NewDataSet")("ds")("FLAG")) & cstr(xo("NewDataSet")("ds")("UNIT").ToString))
Else
msgbox(11)
output.Show(cstr(xo("NewDataSet")("ds")("LISITEMNAME")) & cstr(xo("NewDataSet")("ds")("RESULT")) & cstr(xo("NewDataSet")("ds")("RANGE")) & cstr(xo("NewDataSet")("ds")("FLAG")) & cstr(xo("NewDataSet")("ds")("UNIT")))
End If
End If