这是有效的 XML 标记吗? [英] Is this valid XML tagging?

查看:36
本文介绍了这是有效的 XML 标记吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾认为 xml 必须有一个开始 &结束标记,例如

I had thought xml had to have a start & end tag, for example

<SalesRankings> 1 </SalesRankings>

但是这个是我的XML的jpg,没有遵循上面的格式.我将它粘贴到一个 XML 验证器中 &它没有抛出任何错误,所以它有效吗?

but this is a jpg of my XML, where the above format is not followed. I pasted it into an XML validator & it didn't throw any errors, so is it valid?

<SalesRankings/>

上面的 XML 是否格式错误?

Is the above Malformed XML or not?

推荐答案

是的,它是有效的(或者更确切地说,好吧-形成).

Yes, it is valid (or rather, well-formed).

XML 1.0 规范中,特别是3.1 Start-Tags, End-Tags, and Empty-Element Tags,这种元素被称为空元素标签,其格式正式定义为:

In the XML 1.0 specification, particularly section 3.1 Start-Tags, End-Tags, and Empty-Element Tags, this kind of element referenced as empty-element tag, which format defined formally as :

[44] EmptyElemTag ::= '<'姓名(S 属性)* S?'/>' [WFC:Unique Att Spec]

[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]

规范中的空元素示例:

<IMG align="left"
 src="http://www.w3.org/Icons/WWW/w3c_home" />
<br></br>
<br/>

这篇关于这是有效的 XML 标记吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆