zoukankan      html  css  js  c++  java
  • Xml的一些基本概念

    Document element (also can be called as root element) is needed for a valid xml document.

    Xml namespace is done by defining the Universal Resource Indicator (URIs) which includes Uniform Resource Locators (URL) and Uniform Resource Numbers (URN).

    There are 2 ways to define a namespace:
    1). Default namespace: define it using the xmlns attribute without a prefix. For example: <html xmlns="http://www.w3.org/1999/xhtml">
    2). Prefixed namespace: define it using the xmlns attribute with a prefix. For example: <blist:books xmlns:blist="http://www.wrox.com/books/xml">

    DTD may either be stored internally as part of the XML document or externally in a separate file, accessible via a URL.
    an internal example:

    <?xml version=”1.0” ?>
    <!-- DTD is not parsed as XML, but read by parser for validation -->
    <!DOCTYPE book [
    <!ELEMENT book (title, chapter+)>
    <!ATTLIST book author CDATA #REQUIRED>
    <!ELEMENT title (#PCDATA)>
    <!ELEMENT chapter (#PCDATA)>
    <!ATTLIST chapter id #REQUIRED>
    ]>

    Extensible Stylesheet Language Transformation (XSLT) is a language used for converting XML documents from one format to another. The two below are used mainly:
    1) Converting XML into HTML
    2) Converting XML into another XML

    Document Object Model (DOM): this API will laod the whole xml document into the RAM to do the parsing work. It is well suited for traversing and modifying an XML document, but provides little support for finding an arbitrary element or attribute. Of course it has the lower performance.

    Simple API for XML (SAX): it loads the document as a stream of data parts instead of aggregation. It's straight-forward only.

    Difference between SAX and DOM:
    1) DOM uses a parallel approach to the document, it can access several different level nodes with one method. SAX only can starting at the beginning and responding to its contents once for each node and in the order they appear in the document.
    2) DOM needs larger memory and has a lower performance. SAX needs smaller memory and has a higher performance. So if reading a very big xml document, using SAX is better.

    As DOM doesn't support well for finding an arbitrary element or attribute, XPath can help us to do the work. It is a navigational query language for locating data within an XML document.

  • 相关阅读:
    使用springboot遇到的问题
    npm使用出现的问题
    ORACLE遇到的新知识
    使用linux
    解释ArrayList的源码
    git的基础知识(并不是直接照着抄写的,用到的写过来)
    使用github遇到的问题
    java将数据库中菜单表中内容转化成一个导航树
    使用python自动发放员工工资条到个人邮箱
    zabbix图形中文乱码
  • 原文地址:https://www.cnblogs.com/gamix/p/569933.html
Copyright © 2011-2022 走看看