惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

酷 壳 – CoolShell

感染新冠的经历 | 酷 壳 - CoolShell 从一次经历谈 TIME_WAIT 的那些事 | 酷 壳 - CoolShell 网络数字身份认证术 | 酷 壳 - CoolShell 我做系统架构的一些原则 | 酷 壳 - CoolShell 源代码特洛伊木马攻击 | 酷 壳 - CoolShell Go编程模式 : 泛型编程 | 酷 壳 - CoolShell 如何做一个有质量的技术分享 | 酷 壳 - CoolShell Go 编程模式:k8s Visitor 模式 | 酷 壳 - CoolShell Go编程模式:Pipeline | 酷 壳 - CoolShell Go编程模式:委托和反转控制 | 酷 壳 - CoolShell Go 编程模式:Go Generation | 酷 壳 - CoolShell Go编程模式:Map-Reduce | 酷 壳 - CoolShell Go 编程模式:错误处理 | 酷 壳 - CoolShell Go编程模式:切片,接口,时间和性能 | 酷 壳 - CoolShell 百度为什么掉队了 | 酷 壳 - CoolShell 程序员如何把控自己的职业 | 酷 壳 - CoolShell 计时攻击 Timing Attacks | 酷 壳 - CoolShell Rust语言的编程范式 | 酷 壳 - CoolShell HTTP的前世今生 | 酷 壳 - CoolShell 记一次Kubernetes/Docker网络排障 | 酷 壳 - CoolShell 可视化编程 | 酷 壳 - CoolShell 程序的本质复杂性和元语言抽象 | 酷 壳 - CoolShell 伙伴分配器的一个极简实现 | 酷 壳 - CoolShell C++11的Lambda使用一例:华容道求解 | 酷 壳 - CoolShell C++面试中string类的一种正确写法 | 酷 壳 - CoolShell C++模板”>>”编译问题与词法消歧设计 | 酷 壳 - CoolShell 数据即代码:元驱动编程 | 酷 壳 - CoolShell 数据的游戏:冰与火 | 酷 壳 - CoolShell 7个示例科普CPU Cache | 酷 壳 - CoolShell 加班与效率 | 酷 壳 - CoolShell
信XML,得永生! | 酷 壳 - CoolShell
陈皓 · 2010-06-09 · via 酷 壳 – CoolShell

在计算机的世界里,什么最牛?JavascriptC语言C++iPad?还是brainfuck?我个人觉得都不是,这个世界里,XML最NB,这世界到处都充斥着XML,正如在“十条不错的编程观点”文中所说,我们不用XML我们都不知道怎么编程了。下面,让我们来看一看XML的几个真实的示例,相信你会同意我的观点的。

一、如何用XML返回数据库SQL查询结果

<?xml version="1.0" encoding="iso-8859-1" ?>
<result>
  <fields>
    <field>NAME</field>
    <field>LAST NAME</field>
    <field>MOTHER MAIDEN NAME</field>
    <field>BIRTHDATE</field>
    ...
  </fields>
  <data>
    <row>
      <value>MARLENE</value>
      <value>RUTH</value>
      <value>DE MARCO</value>
      <value>1973-02-24 00:00:00</value>
      ...
    </row>
  </data>
</result>

二、如何用XML序列化一个图片

<attachments xmlns = "http://webservices..." >
  <bytes>37</bytes>
  <bytes>80</bytes>
  <bytes>68</bytes>
  <bytes>70</bytes>
  <bytes>45</bytes>
  <bytes>49</bytes>
  <bytes>46</bytes>
  <bytes>52</bytes>
  <bytes>10</bytes>
  <bytes>37</bytes>
  <bytes>-30</bytes>
  <bytes>-29</bytes>
  <bytes>-49</bytes>
  <bytes>-45</bytes>
  <bytes>10</bytes>
  <bytes>52</bytes>
  <bytes>32</bytes>
  <bytes>48</bytes>
  <bytes>32</bytes>
  <bytes>111</bytes>
  ...
  ...
  ...

三、如何让XML与CSV格式兼容

<?xml version="1.0" encoding="iso8859-1" ?>
<import tag="1stTEST" type="data" mode="update">
<options>
    <dateformat mmddyyyy="true"/>
        <notification>
            <EMail>[email protected]</EMail>
        </notification>
    </options>
    <fields>
        <field name="name" type="char" mapsto="person.data"/>
        <field name="officeid" type="char" mapsto="custom.locationid"/>
        <field name="startyear" type="char" mapsto="person.yearstarted"/>
        <field name="personelid" type="int" mapsto="person.id"/>
        <field name="dob" type="date" mapsto="person.dateofbith"/>
        <field name="sex" type="char" mapsto="person.sex"/>
        <field name="modified" type="date" mapsto="record.modified"/>
    </fields>
    <csvdata columnheaders="false">
<![CDATA[
"Jack Wade",214,2002,111012,07/04/1975,"M",02/11/2006
"Sam Davidson",214,1999,104841,10/15/1967,"M",02/10/2006
"Denise V Law",214,1998,104660,01/21/1971,"F",02/17/2006
"Lisa Blake",214,1989,100987,08/01/1982,"F",01/21/2006
"Andrew Match",214,1991,101074,12/25/1980,"M",02/28/2006
]]>
    </csvdata>
</import>

四、如何把XML当成数组来用

<rootNode>
   <numberOfAddresses>110</numberOfAddresses>
   <address_1>442 Fake St.</address_1>
   <address_2>61 Main St.</address_2>
   ...
   ...
   ...
   <address_110>3881 N 4th Ave. #5D</address_110>
</rootNode>

相信你一定有比这更牛X的例子,欢迎与我们分享!

Loading...