代码之家  ›  专栏  ›  技术社区  ›  Xerri

我可以将除文件以外的任何内容传递给simplexmliterator吗?

  •  0
  • Xerri  · 技术社区  · 15 年前

    我正在尝试将XML字符串转换为和数组。SimpleXmlIterator只接受文件路径作为参数。有没有办法让我通过一根绳子呢?

    3 回复  |  直到 15 年前
        1
  •  2
  •   netcoder    15 年前

    SimpleXMLIterator::__construct ( string $data [, int $options [, bool $data_is_url [, string $ns [, bool $is_prefix ]]]] )
    

    $it = new SimpleXMLIterator ($xml_string);
    

    $it = new SimpleXMLIterator ($xml_filename, 0, true);
    
        2
  •  1
  •   ircmaxell    15 年前

    SimpleXMLIterator constructor true false

    asXml() $filename

        3
  •  1
  •   Gordon Haim Evgi    15 年前

    ctor signature

    SimpleXMLIterator::__construct ( 
        string $data [, 
            int $options [, 
                bool $data_is_url [, 
                    string $ns [, 
                        bool $is_prefix ]]]] )
    

    $data_is_url

    first user-contributed comment in the PHP Manual for SimpleXmlIterator for an example how to turn XML into an array

    推荐文章