XML 加载类

属性
命名空间 fize\xml
类名 SimpleXml
方法:
方法名 说明
importDom() 从一个DOMNode对象返回一个对应的SimpleXMLElement对象
loadFile() 从文件载入xml到一个SimpleXMLElement对象并返回
loadString() 从xml字符串载入到一个SimpleXMLElement对象并返回

方法

importDom()

从一个DOMNode对象返回一个对应的SimpleXMLElement对象

public static function importDom (
    \DOMNode $node,
    string $class_name = "SimpleXMLElement"
) : \SimpleXMLElement
参数:
名称 说明
node  
class_name 要返回的对象类名
返回值:

根据参数$class_name也可能返回SimpleXMLElement扩展类,错误时返回false

参数 `$class_name` :
该类必须是SimpleXMLElement或扩展自SimpleXMLElement。

loadFile()

从文件载入xml到一个SimpleXMLElement对象并返回

public static function loadFile (
    string $filename,
    string $class_name = "SimpleXMLElement",
    int $options = 0,
    string $ns = "",
    bool $is_prefix = false
) : \SimpleXMLElement
参数:
名称 说明
filename 文件路径
class_name string $class_name 要返回的对象类名
options 可选的LIBXML_*参数常量
ns 命名空间前缀或者URI
is_prefix 指定参数$ns是否为命名空间前缀,默认false,即$ns参数是URI
返回值:

根据参数$class_name也可能返回SimpleXMLElement扩展类,错误时返回false

参数 `$class_name` :
该类必须是SimpleXMLElement或扩展自SimpleXMLElement。

loadString()

从xml字符串载入到一个SimpleXMLElement对象并返回

public static function loadString (
    string $data,
    string $class_name = "SimpleXMLElement",
    int $options = 0,
    string $ns = "",
    bool $is_prefix = false
) : \SimpleXMLElement
参数:
名称 说明
data xml字符串
class_name string $class_name 要返回的对象类名
options 可选的LIBXML_*参数常量
ns 命名空间前缀或者URI
is_prefix 指定参数$ns是否为命名空间前缀
返回值:

根据参数$class_name也可能返回SimpleXMLElement扩展类,错误时返回false

参数 `$class_name` :
该类必须是SimpleXMLElement或扩展自SimpleXMLElement。