常用工具: 简繁转换 HTML/JS互转 Url编码Escape解析 Unicode编码转换 设为首页 加入收藏夹
更多内容
" id="arctext" class="center" " class="arcinfo center" " id="slistl" class="left" " id="mid_slistl_sch" class="left" " id="mid_slistl_adv" class="left" " id="mid_slistl_adv2" " src="http://www.fzs8.net/d/js/acmsd/middle2.js"
文章正文

ASP Hex 函数

来源:  网络收集  字体:[ ]
站内搜索系统
文章正文

php xml_parse_into_struct() 函数

来源:  网络收集  2006-10-08 00:00:00 字体:[ ]

Definition and Usage
定义和用法

The xml_parse_into_struct() function parses XML data into an array.
xml_parse_into_struct()函数的作用是:将XML数据解析到一个数组中。

This function parses the XML data into 2 arrays:
这个函数将XML数据解析成2个数组:

  • Value array - containing the data from the parsed XML
    Value array –包含了解析的XML数据
  • Index array - containing pointers to the location of the values in the Value array
    Index array –包含了定位数组值的指针

This function returns 1 on success, or 0 on failure.
如果函数成功执行,将返回1;如果执行失败,将返回0。

Syntax
语法

xml_parse_into_struct(parser,xml,value_arr,index_arr)

Parameter
参数
Description
描述
parser Required. Specifies XML parser to use
必要参数。指定需要解析的XML
xml Required. Specifies XML data to parse
必要参数。指定需要解析的XML数据
value_arr Required. Specifies the target array for the XML data
必要参数。指定XML数据的目标数组[the target array for the XML data]
index_arr Optional. Specifies the target array for index data
可选参数。指定索引数据的目标数组[the target array for index data]


Tips and Notes
注意点

Note: The xml_parse_into_struct() function returns 1 for success and 0 for failure.  This is not the same as TRUE and FALSE.
注意:xml_parse_into_struct()函数如果成功执行,将返回1(不是True);如果执行失败,将返回0(不是False)。


Example
案例

XML File
XML文件

<?xml version="1.0" encoding="ISO-8859-1"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

PHP Code
PHP 代码

<?php//invalid xml file$xmlfile = 'test.xml';$xmlparser = xml_parser_create();
// open a file and read data$fp = fopen($xmlfile, 'r');$xmldata = fread($fp, 4096);
xml_parse_into_struct($xmlparser,$xmldata,$values);
xml_parser_free($xmlparser);print_r($values);?>

The output of the code above will be:
上述代码将输出下面的结果:

Array([0] => Array  (  [tag] => NOTE  [type] => open  [level] => 1  [value] =>  )  [1] => Array    (    [tag] => TO    [type] => complete    [level] => 2    [value] => Tove    )[2] => Array  (  [tag] => NOTE  [value] =>  [type] => cdata  [level] => 1  )  [3] => Array    (    [tag] => FROM    [type] => complete    [level] => 2    [value] => Jani    )[4] => Array  (  [tag] => NOTE  [value] =>  [type] => cdata  [level] => 1  )  [5] => Array    (    [tag] => HEADING    [type] => complete    [level] => 2    [value] => Reminder    )[6] => Array  (  [tag] => NOTE  [value] =>  [type] => cdata  [level] => 1  )  [7] => Array    (    [tag] => BODY    [type] => complete    [level] => 2    [value] => Don't forget me this weekend!    )[8] => Array  (  [tag] => NOTE  [value] =>  [type] => cdata  [level] => 1  )[9] => Array  (  [tag] => NOTE  [type] => close  [level] => 1  ))


  
上一篇:php xml_parse() 函数
下一篇:php xml_parser_create_ns() 函数
最新文章
推荐文章
热门文章
版权所有:IT加油站   COPYRIGHT © 2007 WWW.FZS8.NET ALL RIGHTS RESERVED.
闽ICP备08008535号