使用PHP生成和获取XML格式数据

时间:2022-09-17 10:08:06

1.php生成xml

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgMAAADuCAIAAAAr/JN1AAAWbklEQVR4nO2dQZbjOA5Edd2+VV9jdrrCXGNOMYvuyqcUiGCAomzZ/H9Rj6KgQJC2gHKlnLX957//+/vvv//6668NAADWhE4AALA6dAIAgNWhEwAArA6dAABgdegEAACrQycAAFidn06w7/u+7z/zp8MBTIX9N9m8acaP12HCkmPjjZS2CwBg20In+KeCTKkm1fIdLzkelvrKLIcx4COK7EeYBIAHETtB9a/h18kq/gM7QTXFWxAOX/zKAsBn4HSCZm84zmSn9tZfqLN5fyzQ4plmJl6dz2Iu7k9XP0snUnT1AWAh4s8JRHHMqo+oa82kThXbfldGs3h1bTT1M7f+EnTAlbGj37xcrAsA4BfOT4yziqwrTjaT6fhjgbARfXb1s6SOGSEucjX3R+sPrAsA4BfdTlCtaNlZU+diRYthVyqmP6mdODrVkj22rv0PfiIA+H4e1Qn8S8ykF/XjpF9GndLsjJ0U1a02lwAAq1D616EtVB9RQGNAV6dZs0rFS0iJRW15xWzqmDTXm4mLea1fWtfAKgDg++E7xktBGwCABnQCAIDVoRMAAKwOnQAAYHXoBAAAq0MnAABYHToBAMDqZL+Bbnqi+5THeLuftxsAAPiX42eC5jeVNAPftKp7vIu3+3m7AQCAbUs6weYVqWohe1rhe7uftxsAANg2rxM0/9VoDzRPHXNdiXfmM7TOFiqys96m/mbsm5YCAHgDpc8EzeIoxEV8V786djxkxf0OP7P8AwDcTvUzQVbZjzjxw/p7QC9QxJT8jI19HQCAt9HtBKJyiUrdjXf0/aQCEV/yc2XcTQoA8E66zw45lb0aX722Wm2P3O3n5/CHuf4BAG7H+T7BcTIrgt340yATiYVS6JtltBl/mmnmbfqPm3DS7PrM1gsA8B74jvFFnA4BAPBo6ATXqX5GAQB4FnQCAIDVoRMAAKwOnQAAYHXoBAAAq0MnAABYndP3CX7mrz8JYyrsv8nmTTN+vA4T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Bd8Bhdeg3Rzvu2mLQGTBd6B9xkQrIXJAgD5MFkAIB8mCwDkw2QBgHyYLACQD5MFAPJhsgBAPku/N+SCTxzo7Jaf3fRU5235ZLJUYbf87KanOm/L53WynA3dxdz1T8Wtsr5bfnbTU31dymd5eM5Shd3ys5ue6rwtn0yWKuyWn930VOdt+eS9IQDIh8kCAPkwWQAgHyYLAOTDZAGAfJgsAJAPkwUA8mGyAEA+TBYAyOdnspT78kIJkX+4SfXmWbL/VL0KZR4+xm2yfFqOg48IDkTsjgPpoX27108u5boFnqbuZHmeQIraLdcVy9MNyd7rJx0aBjTCk0Xq8uP3s/TbYvdh194SWgo648fo3xKia3ZL2tCVZO/14z2vxbMxD/CNSK+zWPa2zX30RkZ73e7t2hijD2MNt3s1xxTeFtvj607O3kAJ+Jm8Hh4Q4DiE94aMHXP+5TBMCuVOiDXobVfAYdfsbNDtZ/xbfEr2Xj8WPd4cxgoHX8H8ZFEWu9fSnTB533rvCosf3TLg/LjcyUafkn1gEHQtpY1GYZaI8I10X2cxNk3XTPFzuyuG9q7oXj8WDRb9MzqlhxZ73UyXMXNtDAffjvR3cIcbFWPpR/pdYW/Ws+HwT5ahTv1oFp23XZL+oX/JXvGjyLCfV18fhoOvhs/gAkA+TBYAyIfJAgD5MFkAIB8mCwDkw2QBgHT+C7w4tHPKYMaXAAAAAElFTkSuQmCC" alt="" />

代码如下:

<?php
header("content-type:text/html;charset=utf-8");
$con = mysql_connect('localhost','root','root');
mysql_query('set names utf8');
$db = mysql_select_db('wh'); // var_dump($con,$db);
$sql = "select * from stu";
$res = mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_assoc($res)){
$arr[] = array(
'name' => $row['name'],
'age' => $row['age'],
'email' => $row['email'] );
} $doc = new DOMDocument('1.0', 'utf-8'); // 声明版本和编码 // var_dump($doc);
$doc->formatOutput = true; $r = $doc->createElement("root");
$doc->appendChild($r); foreach ($arr as $dat) {
$b = $doc->createElement("data"); $name = $doc->createElement("name");
$name->appendChild($doc->createTextNode($dat['name']));
$b->appendChild($name); $sex = $doc->createElement("age");
$sex->appendChild($doc->createTextNode($dat['age']));
$b->appendChild($sex); $age = $doc->createElement("email");
$age->appendChild($doc->createTextNode($dat['email']));
$b->appendChild($age); $r->appendChild($b);
} echo $doc->saveXML(); ?>

 2.读取xml文件信息

a.准备xml文件: f.xml。如:

<?xml version="1.0" encoding="utf-8"?>
<root>
<data>
<name>wuheng</name>
<age>23</age>
<email>demo@qq.com</email>
</data>
<data>
<name>wuheng009</name>
<age>22</age>
<email>dem6@qq.com</email>
</data>
<data>
<name>wuheng555</name>
<age>22</age>
<email>dem6@qq.com</email>
</data>
<data>
<name>xia</name>
<age>11</age>
<email>456@qq.com</email>
</data>
<data>
<name>xia11</name>
<age>12</age>
<email>466@qq.com</email>
</data>
</root>

b.具体的代码,如下:

<?php
header("content-type:text/html;charset=utf-8");
$url = "f.xml";
$reader = new XMLReader(); //实例化XMLReader
$reader->open($url); //获取xml
$i=1;
while ($reader->read()) {
if ($reader->nodeType == XMLReader::TEXT) { //判断node类型
$m = $i%3;
if($m==1)
$name = $reader->value; //读取node值
if($m==2)
$age = $reader->value;
if($m==0){
$email = $reader->value;
$arr[] = array(
'name' => $name,
'age' => $age,
'email' => $email
);
}
$i++;
}
}
print_r($arr); ?>

使用PHP生成和获取XML格式数据的更多相关文章

  1. PHP生成和获取XML格式数据

    在做数据接口时,我们通常要获取第三方数据接口或者给第三方提供数据接口,而这些数据格式通常是以XML或者JSON格式传输,本文将介绍如何使用PHP生成XML格式数据供第三方调用以及如何获取第三方提供的X ...

  2. Android使用DOM生成和输出XML格式数据

    Android使用DOM生成和输出XML格式数据 本文主要简单解说怎样使用DOM生成和输出XML数据. 1. 生成和输出XML数据 代码及凝视例如以下: try { DocumentBuilderFa ...

  3. MySQL获取XML格式数据

    通过再调用mysql工具时使用--xml选项: C:\Users\wang>mysql -uroot -p --xml mydb Enter password: ******** Welcome ...

  4. XML&lpar;php中获取xml文件的方式&sol;ajax获取xml格式的响应数据的方式&rpar;

    1.XML 格式规范: ① 必须有一个根元素 ② 不可有空格.不可以数字或.开头.大小写敏感 ③ 不可交叉嵌套 ④ 属性双引号(浏览器自动修正成双引号了) ⑤ 特殊符号要使用实体 ⑥ 注释和HTML一 ...

  5. Android中解析XML格式数据的方法

    XML介绍:Extensible Markup Language,即可扩展标记语言 一.概述 Android中解析XML格式数据大致有三种方法: SAX DOM PULL 二.详解 2.1 SAX S ...

  6. R语言XML格式数据导入与处理

    数据解析 XML是一种可扩展标记语言,它被设计用来传输和存储数据.XML是各种应用程序之间进行数据传输的最常用的工具.它与Access,Oracle和SQL Server等数据库不同,数据库提供了更强 ...

  7. yii2 输出xml格式数据

    作者:白狼 出处:http://www.manks.top/yii2_xml_response.html.html本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文 ...

  8. jQuery获取JSON格式数据方法

    getJSON方法: jQuery.getJSON(url,data,success(data,status,xhr)) $("button").click(function(){ ...

  9. wemall app商城源码Android 获取XML网络数据并绑定到ListView

    wemall-mobile是基于WeMall的android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改.本文分享Android 获取XML网络数据并绑定到Li ...

随机推荐

  1. ASP&period;NET MVC企业级实战目录

    电子书样稿 (关注最新进度,请加QQ群:161436236) ASP.NET MVC企业实战第1章 MVC开发前奏.pdf ASP.NET MVC企业实战第10章 站内搜索.pdf 已经好长一段时间没 ...

  2. &lbrack;Python&rsqb; 利用commands模块执行Linux shell命令

    http://blog.csdn.net/dbanote/article/details/9414133 http://zhou123.blog.51cto.com/4355617/1312791

  3. this及其作用域(函数外部this变量的调用)

    众所周知的一件麻烦事是函数外部的this变量都不可见,但是我们在编写使用局部函数的方法时,却又很可能需要在某一时刻从内部函数访问this变量. 这种情况下可以通过在this变量中存储一个需要的信息(例 ...

  4. Android 自定义View修炼-打造完美的自定义侧滑菜单&sol;侧滑View控件

    一.概述 在App中,经常会出现侧滑菜单,侧滑滑出View等效果,虽然说Android有很多第三方开源库,但是实际上 咱们可以自己也写一个自定义的侧滑View控件,其实不难,主要涉及到以下几个要点: ...

  5. MVVM Light 一个窗口承载两个视图

    MVVM Light 一个窗口承载两个视图   原文地址:http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views 本文 ...

  6. Spring&plus;Mybatis&plus;SpringMVC后台与前台分页展示实例(附工程)(转)

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文实现了一个后台由Spring+Mybatis+SpringMVC组成,分页采用Pag ...

  7. Application对象

    Application对象报讯是应用程序参数的额,多个用户可以共享一个Application.用于启动和管理ASP.NET应用程序. Count  属性 获取Application对象变量的个数,集合 ...

  8. Allow Only Ajax Requests For An Action In ASP&period;NET Core

    ASP.NET Core offers attributes such as [HttpGet] and [HttpPost] that allow you to restrict the HTTP ...

  9. JVM总括:目录

    JVM总括:目录 JVM总括一-JVM内存模型 JVM总括二-垃圾回收:GC Roots.回收算法.回收器 JVM总括三-字节码.字节码指令.JIT编译执行 JVM总括四-类加载过程.双亲委派模型.对 ...

  10. maven打包证(支付)书问题

    要将证书文件后缀添加到resource文件夹内范围,添加打包文件后缀(include) 添加maven配置: <resources> <resource> <direct ...