XML:这有效吗?

发布于 2024-08-15 17:05:26 字数 779 浏览 4 评论 0原文

以下 XML 声明有效吗?

<message metadata="SomeMetaData" xsi:nil="true"/>

其中 xsi 定义为“http://www.w3.org/2001/XMLSchema-instance

如果我尝试创建上述数据以通过 ASP 传输C# 中的 .NET Web 服务应用程序,如何对上述内容进行编码?

举例来说,我有一个用 C# 编写的 Web 服务方法,名为“

SomeMethod(Msg someMessage)

如何指示 Msg 类中找到的 message”字段包含一个名为 metadata 的属性> 并且字段 message 本身也是一个可以为 null 的元素(不包含数据,如下例所示)?

<message metadata="SomeMetaData"></message>

在其他情况下,它可以包含一些数据,如下所示:

<message metadata="SomeMetaData">
    <data>1234</data>
    <data>5678</data>
</message>

Is the following XML declaration valid?

<message metadata="SomeMetaData" xsi:nil="true"/>

where xsi is defined as "http://www.w3.org/2001/XMLSchema-instance"

If I am trying to create the above data for transfer through a ASP.NET Web Service Application in C#, how do I go about coding the above?

Say for example I have a web service method written in C# called

SomeMethod(Msg someMessage)

How to I indicate that the message field found in class Msg contains an attribute called metadata and that the field message itself is also an element which can be null(contains no data as shown in following example)?

<message metadata="SomeMetaData"></message>

In other cases, it can contain some data as follows:

<message metadata="SomeMetaData">
    <data>1234</data>
    <data>5678</data>
</message>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静待花开 2024-08-22 17:05:26

如果定义了“xsi”命名空间,则 XML 有效。

“创建上述数据”是什么意思?例子?

The XML is valid, provided that the "xsi" namespace is defined.

What do you mean by "create the above data"? Example?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文