DOMXML函数笔记
<?php /** * DOMXML函数笔记 * 连接php_domxml.dll后 * 用get_defined_functions()得到domxml支持函数 * * 目前domxml不支持非iso-8859-1以外的语言声明 * <?xml version="1.0" encoding="iso-8859-1"?> 支持 * <?xml version="1.0" encoding="gb2312"?> 不支持 * <?xml version="1.0"?> 因此需要改造成这样,可能需要 * utf8_encode() utf8_decode() 函数进行处理 * * 函数列表 * string domxml_version(void) 返回domxml的版本号 * object xmldoc(string str) 从字符串创建XML的Domdocument对象 * object xmldocfile(string filename) 从文件创建XML的Domdocument对象 * object xmltree(string str) 解析xml文档,返回树状结构,不能用domxml函数改变 * resource domxml_add_root(resource doc,string name) 添加根节点 * string domxml_dumpmem(resource doc) 将domxml对象转化为XML串。这个函数有一个问题,他会在第一个汉字前面加一个扩展ascii字符,形如nnn; * domxml_node_attributes * domxml_elem_get_attribute * domxml_elem_set_attribute * array domxml_node_children(object doc|node) 返回子节点 * domxml_node_new_child * object domxml_node(string name) 创建一个节点节点 * domxml_node_unlink_node * int domxml_node_set_content(resource doc,string content) 设置节点内容 * object domxml_new_xmldoc(string version) 创建新的空XML对象 * xpath_new_context * xpath_eval * xpath_eval_expression * xptr_new_context * xptr_eval * object domxml_root(object doc) 返回根节点 * array domxml_attributes(resource note) 获取节点属性 * object domxml_get_attribute(resource doc,string name) 读取属性 * domxml_getattr * object domxml_set_attribute(resource doc,string name,string value) 添加属性 * domxml_setattr * array domxml_children(object doc|node) 返回子节点 * resource domxml_new_child(string name,string content) 添加子节点 * domxml_unlink_node * set_content * new_xmldoc * */ ?> <pre> <?php // 文档 xml源树.xml 内容 $testxml = '' <?xml version="1.0" encoding="GB2312"?> <root> <note>读取xml文档时,处理器将形成一个树,我们将其叫做源树。该树具有表中的各种类型的节点。 </note> <title> |
查看所有评论
