• <i id='Dw4kp'><tr id='Dw4kp'><dt id='Dw4kp'><q id='Dw4kp'><span id='Dw4kp'><b id='Dw4kp'><form id='Dw4kp'><ins id='Dw4kp'></ins><ul id='Dw4kp'></ul><sub id='Dw4kp'></sub></form><legend id='Dw4kp'></legend><bdo id='Dw4kp'><pre id='Dw4kp'><center id='Dw4kp'></center></pre></bdo></b><th id='Dw4kp'></th></span></q></dt></tr></i><div id='Dw4kp'><tfoot id='Dw4kp'></tfoot><dl id='Dw4kp'><fieldset id='Dw4kp'></fieldset></dl></div>
      <bdo id='Dw4kp'></bdo><ul id='Dw4kp'></ul>
  • <legend id='Dw4kp'><style id='Dw4kp'><dir id='Dw4kp'><q id='Dw4kp'></q></dir></style></legend>
  • <small id='Dw4kp'></small><noframes id='Dw4kp'>

    1. <tfoot id='Dw4kp'></tfoot>

        XML 文件中的自闭合标签

        时间:2023-07-31
        <legend id='ntlUv'><style id='ntlUv'><dir id='ntlUv'><q id='ntlUv'></q></dir></style></legend>
        <tfoot id='ntlUv'></tfoot>

          <bdo id='ntlUv'></bdo><ul id='ntlUv'></ul>
          <i id='ntlUv'><tr id='ntlUv'><dt id='ntlUv'><q id='ntlUv'><span id='ntlUv'><b id='ntlUv'><form id='ntlUv'><ins id='ntlUv'></ins><ul id='ntlUv'></ul><sub id='ntlUv'></sub></form><legend id='ntlUv'></legend><bdo id='ntlUv'><pre id='ntlUv'><center id='ntlUv'></center></pre></bdo></b><th id='ntlUv'></th></span></q></dt></tr></i><div id='ntlUv'><tfoot id='ntlUv'></tfoot><dl id='ntlUv'><fieldset id='ntlUv'></fieldset></dl></div>
            <tbody id='ntlUv'></tbody>

                • <small id='ntlUv'></small><noframes id='ntlUv'>

                • 本文介绍了XML 文件中的自闭合标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  <tag id="foo"/>

                  我注意到它们可以使用 PHP SimpleXML.

                  但是我在网上找到的所有 XML 示例都以旧方式关闭它们:

                  <tag id="foo"></tag>

                  我有什么理由应该使用旧方法吗?

                  解决方案

                  查看 XML 和 XHTML 的 W3C 规范:

                  • 中定义为

                    <块引用>

                    这个词或形容词推荐"的意思是在特定情况下可能存在忽略特定项目,但必须了解全部含义并在选择不同的课程之前仔细权衡.

                    如果您正在使用没有 DTD 或模式的 XML,您还可以使用 预定义的 libxml 常量:

                    <块引用>

                    LIBXML_NOEMPTYTAG(整数):将空标签(例如 <br/> 扩展为 <br></br>)

                    但请注意,此选项目前仅在函数 DOMDocument::saveDOMDocument::saveXML 中可用,因此您不能将其与 SimpleXml 一起使用.

                    <tag id="foo" />

                    I noticed that they work with PHP SimpleXML.

                    But all XML examples I found on the web close them the old way:

                    <tag id="foo"></tag>

                    Is there any reason why I should use the old method?

                    解决方案

                    See the W3C specs for XML and XHTML:

                    • http://www.w3.org/TR/xml/#sec-starttags
                    • http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict

                    It depends on the Element Type declaration

                    An element with no content is said to be empty. The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag.

                    but also

                    Empty-element tags may be used for any element which has no content, whether or not it is declared using the keyword EMPTY. For interoperability, the empty-element tag SHOULD be used, and SHOULD only be used, for elements which are declared EMPTY.

                    This means, when your DTD contains something like

                    <!ELEMENT img EMPTY>
                    

                    you should use

                    <img/>
                    

                    unless you have good reason to use

                    <img></img>
                    

                    Note that SHOULD is defined in RFC2119 as

                    This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

                    If you are working with XML that does not have a DTD or Schema, you can also influence how the XML is serialized with a predefined libxml constant:

                    LIBXML_NOEMPTYTAG (integer): Expand empty tags (e.g. <br/> to <br></br>)

                    But note that this option is currently just available in the functions DOMDocument::save and DOMDocument::saveXML, so you cannot use it with SimpleXml.

                    这篇关于XML 文件中的自闭合标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 HTML5 中,&lt;header&gt;和&lt;页脚&gt;标签出现在 &am 下一篇:计算所选文本 javascript/JQuery 的位置?

                  相关文章

                    <bdo id='iwP1D'></bdo><ul id='iwP1D'></ul>
                  <legend id='iwP1D'><style id='iwP1D'><dir id='iwP1D'><q id='iwP1D'></q></dir></style></legend>
                  <tfoot id='iwP1D'></tfoot>

                    <i id='iwP1D'><tr id='iwP1D'><dt id='iwP1D'><q id='iwP1D'><span id='iwP1D'><b id='iwP1D'><form id='iwP1D'><ins id='iwP1D'></ins><ul id='iwP1D'></ul><sub id='iwP1D'></sub></form><legend id='iwP1D'></legend><bdo id='iwP1D'><pre id='iwP1D'><center id='iwP1D'></center></pre></bdo></b><th id='iwP1D'></th></span></q></dt></tr></i><div id='iwP1D'><tfoot id='iwP1D'></tfoot><dl id='iwP1D'><fieldset id='iwP1D'></fieldset></dl></div>
                  1. <small id='iwP1D'></small><noframes id='iwP1D'>