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.

  • 相关阅读:
    意外发现在调用Activator.CreateInstance的时候在构造函数处加断点居然可以~~
    手机操作系统
    读取Excel文件到DataSet
    支持mrp软件的手机(MTK手机)检测
    如何查看手机系统版本
    .NET进度条用例
    dos命令导出指定类型的文件列表
    FTP上传下载 FTP操作类 FTPHelper 异步上传 递归创建文件文件夹
    批量删除GridView(DataGrid)选中项
    sql判断临时表是否存在
  • 原文地址:https://www.cnblogs.com/gamix/p/569933.html
Copyright © 2011-2022 走看看