[英]what is the difference between xml code
I have been working on webservice and came across thsi: 我一直在从事网络服务,遇到了以下问题:
What is the difference between: 之间有什么区别?
<string xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://companyx.net/" xsi:nil="true"/>
And 和
<string xmlns="http://companyx.net/">[]</string>
The reason for asking is because I coded (try) a webservice and if I invoke it I get <string xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://companyx.net/" xsi:nil="true"/>
and other web service method I look at returns <string xmlns="http://companyx.net/">[]</string>
when invoked. 提出问题的原因是因为我编码(尝试)了一个Web服务,如果我调用它,则会得到<string xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://companyx.net/" xsi:nil="true"/>
和其他我查看的Web服务方法会返回<string xmlns="http://companyx.net/">[]</string>
调用时。 I know the second method returns a array of items, and I need to do that to. 我知道第二种方法返回一个项目数组,我需要这样做。 I want to return a list of contacts. 我想返回联系人列表。
My web service code: 我的网络服务代码:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
Public Function ContactGet(ByVal searchField As String) As String
Dim objSearch As New ArrayList
Dim objSearching As New Search
Dim intResult As Integer
Try
intResult = objSearching.SearchByKeyword(searchField, Session("Person"), Session("Office"), Session("Organisation"), _
Session("Role"), companyx.CXMyProperty.Search.enmSearchType.enmContact, objSearch)
Dim objContact As New Person
Dim dt As New DataTable("Contacts")
Dim col_Name As New DataColumn("Name", GetType(String))
dt.Columns.Add(col_Name)
Dim col_Mobile As New DataColumn("Mobile", GetType(String))
dt.Columns.Add(col_Mobile)
Dim col_Office As New DataColumn("ContactNum", GetType(String))
dt.Columns.Add(col_Office)
Dim col_Category As New DataColumn("Category", GetType(String))
dt.Columns.Add(col_Category)
Dim dr As DataRow
'add new row to datatable
For Each objSearching In objSearch
dr = dt.NewRow()
dr("Name") = objContact.FullName
dr("Mobile:") = objContact.MobileNumber
dr("ContactNum") = objContact.OfficeNumber
dr("Category") = objContact.PersonRelationshipType
dt.Rows.Add(dr)
Next
Dim serializer As New JavaScriptSerializer()
Dim rows As New List(Of Dictionary(Of String, Object))()
Dim row As Dictionary(Of String, Object) = Nothing
'serialize dt row to json output
For Each drow As DataRow In dt.Rows
row = New Dictionary(Of String, Object)()
For Each col As DataColumn In dt.Columns
row.Add(col.ColumnName, dr(col))
Next
rows.Add(row)
Next
Dim str_json = JsonConvert.SerializeObject(dt, Formatting.Indented)
Return str_json
Catch ex As Exception
Return Nothing
End Try
End Function
Im not sure if I coded the web service correctly. 我不确定我是否正确编码了Web服务。 Very new to this. 这很新。
The differences between them are that in one case the string element has an xsi:nil attribute and in the other case it has a "[]" text node child. 它们之间的区别在于,在一种情况下,字符串元素具有xsi:nil属性,在另一种情况下,它具有“ []”文本节点子级。
These might or might not have similar or identical semantics: you need to ask the folks at companyx.net, who designed this vocabulary. 它们的语义可能相同或不相同:您需要在companyx.net上询问设计此词汇表的人员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.