• XML Namespace


    http://www.w3schools.com/xml/xml_namespaces.asp

    XML Namespaces provide a method to avoid element name conflicts.

    When using prefixes in XML, a so-called namespace for the prefix must be defined.

    The namespace is defined by the xmlns attribute in the start tag of an element.

    The namespace declaration has the following syntax. xmlns:prefix="URI".

    <root>

    <h:table xmlns:h="http://www.w3.org/TR/html4/">
      <h:tr>
        <h:td>Apples</h:td>
        <h:td>Bananas</h:td>
      </h:tr>
    </h:table>

    <f:table xmlns:f="http://www.w3schools.com/furniture">
      <f:name>African Coffee Table</f:name>
      <f:width>80</f:width>
      <f:length>120</f:length>
    </f:table>

    </root>

    In the example above, the xmlns attribute in the <table> tag give the h: and f: prefixes a qualified namespace.

    When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace.

    Namespaces can be declared in the elements where they are used or in the XML root element:

    <root
    xmlns:h="http://www.w3.org/TR/html4/"
    xmlns:f="http://www.w3schools.com/furniture"
    >

    <h:table>
      <h:tr>
        <h:td>Apples</h:td>
        <h:td>Bananas</h:td>
      </h:tr>
    </h:table>

    <f:table>
      <f:name>African Coffee Table</f:name>
      <f:width>80</f:width>
      <f:length>120</f:length>
    </f:table>

    </root>

    Note: The namespace URI is not used by the parser to look up information.

    The purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information.

  • 相关阅读:
    组合总和
    子集Ⅱ
    子集
    全排列Ⅱ
    全排列
    填充下一个结点下一个Next结点
    把二叉树转化成累加树
    二叉树的左叶子之和
    高速C/C++编译工具ccache
    【转载】如何用U盘制作Ubuntu启动盘
  • 原文地址:https://www.cnblogs.com/wucg/p/2093560.html
Copyright © 2020-2023  润新知