通过XPath查询XML中的数据
来源:互联网 发布:广西公务员待遇 知乎 编辑:程序博客网 时间:2024/05/14 21:24
一 代码
<?php class Message_XML extends DomDocument{private $Root;public function __construct() {parent:: __construct();$this->load("Rss.xml");}public function select_message($Action){$Root = $this->documentElement;$xpath = new DOMXPath($this);$node_Record = $xpath->query("//item[title='$Action']"); for($i=0;$i<$node_Record->length;$i++){$g=0;foreach($node_Record->item($i)->childNodes as $node){ $field[$g]=iconv("UTF-8","GB2312",$node->textContent);$g++;}print "<table width='750' height='75' border='1' cellpadding='1' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#0099FF'> <tr> <td width='126' height='25' align='center'><span class='STYLE_select5'>标题</span></td> <td width='611'><input name='title' type='text' id='title' size='50' value='$field[0]'></td> </tr> <tr> <td height='25' align='center'><span class='STYLE_select5'>链接地址</span></td> <td><input name='link' type='text' id='link' size='60' value='$field[1]'></td> </tr> <tr> <td height='25' align='center'><span class='STYLE_select5'>内容摘要</span></td> <td><textarea name='description' cols='80' rows='5' id='description'>$field[2]</textarea></td> </tr></table>"; } } }?><title>查询XML文件</title><style type='text/css'><!--.STYLE_select5 {font-size: 13px; font-weight: bold; color: #FFFFFF; }--></style><style type="text/css"><!--body,td,th {font-size: 13px;}a:link {text-decoration: none;}a:visited {text-decoration: none;}a:hover {text-decoration: none;}a:active {text-decoration: none;}.STYLE2 {font-size: 18px}--></style><body><table width=750 height=35 border=1 cellpadding=3 cellspacing=1 bordercolor="#FFFFFF" bgcolor="#0099FF"> <form name="form1" method="post" action="index.php"> <tr> <td height=35 align="center"><span class="STYLE_select5">请输入标题名称:</span> <input name="Action" type="text" id="Action"> <input type="submit" name="Submit" value="提交"> </td> </tr> </form> <?php if($_POST[Submit]==true){ $HawkXML = new Message_XML; $HawkXML->select_message(iconv("GB2312","UTF-8","$_POST[Action]")); }?></table></body>
二 运行结果
阅读全文
0 0
- 通过XPath查询XML中的数据
- dom4j通过xpath查询xml
- Dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- dom4j通过xpath查询xml
- XML中的XPath查询语法
- XML中的XPath查询语法
- dom4j通过xpath查询xml (转)
- php通过xpath解析xml数据
- 通过xpath查询xml中的节点并修改节点元素值
- 使用Xpath查询xml文档节点数据
- XML中的XPath查询语法【转载】
- 设置虚拟机网络连接方式
- leetcode
- 虚拟机宕机了怎么办
- WebStorm WiFi真机同步无法安装成功及appLoader无法连接
- C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法
- 通过XPath查询XML中的数据
- 遍历二叉树
- 设计模式(五)——工厂方法模式
- 链表翻转 快速排序
- java 发送http和https请求
- PHP动态添加XML中的数据
- PHP动态删除XML数据
- XMLHttpRequest对象读取HTML文件
- 语言开发必备:PHP如何防止XSS攻击