<?php
$content = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<test>
<global_setting>
<ping_protocol>HTTP</ping_protocol>
<ping_port>80</ping_port>
<ping_path>/index.html</ping_path>
<response_timeout>5000</response_timeout>
<health_check_interval>3000</health_check_interval>
<unhealthy_threshold>2</unhealthy_threshold>
<healthy_threshold>3</healthy_threshold>
</global_setting>
<instances>
<instance ip="192.168.234.121"/>
<instance ip="192.168.234.28"/>
</instances>
</test>
XML; $test = new SimpleXMLElement($content); //获得ping_protocol的值
$ping_protocol = $test->global_setting->ping_protocol;
echo "ping_protocol : $ping_protocol \n"; //打印出所有instance的IP
foreach ( $test->instances->instance as $instance) {
echo "IP: {$instance['ip']} \n" ;
} //经过我的测试,发现试用var_dump之类的似乎不能有效输出值,用echo比较顺利,还有就是上面的那个xml的例子可以去掉<?xml version="1.0" encoding="UTF-8"?> 也可以去掉头尾///的<<<xml,然后当做普通字符串那样对待,但是没有测试中文等

最新文章

  1. [转]看部电影,透透彻彻理解IoC(你没有理由再迷惑!)
  2. 配置文件类 Properties
  3. Qt——设计颜色编辑器
  4. Rainyday.js – 使用 JavaScript 实现雨滴效果
  5. 《DSP using MATLAB》示例Example4.7
  6. FindProcDLL::FindProc 和 KillProcDLL::KillProc,必须使用WPF x86编译出来的程序
  7. 【WinRT】国内外 Windows 应用商店应用开发者博客收集
  8. 20135316王剑桥 linux第二周课实验笔记
  9. pap与chap协议
  10. android的个人代码总结
  11. MapXtrem + Asp.net 地图随窗体改变大小
  12. XJOI1424解压字符串
  13. 【技巧】datagrid锁定列后重新加载时出现错位问题的解决
  14. Android实现购物车功能
  15. UITableView 之 点击cell 实现两个自定义cell之间的切换
  16. SSO 基于CAS实现单点登录 实例解析(二)
  17. 【spring实战第五版遇到的坑】3.1中的例子报错
  18. C#二维码与条形码的生成
  19. 1.5 A better alternative thing: React Native
  20. ERP服务启动后无法连接数据库的解决方法

热门文章

  1. system.setting-全局变量数据监听
  2. https://github.com/ 英文库
  3. 记号(notation)的学习
  4. 体验SUSE (附视频演示)
  5. 通过NFS、FTP、HTTP三种方法安装Redhat Linux (高清版)
  6. Navigator对象关于语言的属性
  7. BZOJ1023: [SHOI2008]cactus仙人掌图(仙人掌)
  8. [Vue + TS] Use Properties in Vue Components Using @Prop Decorator with TypeScript
  9. IIS7性能优化
  10. 8.spring-boot配置log4j