我怎么取得图中的那个值  刚接触这个,想边做边学,请指教,谢谢

解决方案 »

  1.   

    $b=Tencent::api("friends/fanslist",
    array( "format" => "xml", "reqnum" => "20", "startindex" => "0", "mode" => "0", "install" => "0", "sex" => "0")
    ,"get",false);
    print_r(json_decode($b,true));
    echo"<br>";
    echo"-------------------------------";
      

  2.   

    是XML的   
    print_f结果:<root>
        <data>
            <curnum>
                20
            </curnum>
            <hasnext>
                0
            </hasnext>
            <info>
                <city_code>
                    29
                </city_code>
                <country_code>
                    1
                </country_code>
                <fansnum>
                    100
                </fansnum>
                <head>
                    http://app.qlogo.cn/mbloghead/ec086f8e8265338f812c
                </head>
                <https_head>
                    https://app.qlogo.cn/mbloghead/ec086f8e8265338f812c
                </https_head>
                <idolnum>
                    247
                </idolnum>
                <isfans>
                    true
                </isfans>
                <isidol>
                    true
                </isidol>
                <isrealname>
                    1
                </isrealname>
                <isvip>
                    0
                </isvip>
                <location>
                    中国 大理
                </location>
                <name>
                    shoujini00
                </name>
                <nick>
                    倪旺达
                </nick>
                <openid>
                    DFEE460F0FD097462CFA8576D43E5B01
                </openid>
                <province_code>
                    53
                </province_code>
                <sex>
                    1
                </sex>
                <tag/>
                <tweet>
                    <from>
                        腾讯微博
                    </from>
                    <id>
                        189275000692680
                    </id>
                    <text>
                        克大理闲!
                    </text>
                    <timestamp>
                        1374646496
                    </timestamp>
                </tweet>
            </info>
            <info>
                <city_code>
                    4
                </city_code>
                <country_code>
                    1
                </country_code>
                <fansnum>
                    217
                </fansnum>
                <head>
                    http://app.qlogo.cn/mbloghead/b76a55db336bd8da47e2
                </head>
                <https_head>
                    https://app.qlogo.cn/mbloghead/b76a55db336bd8da47e2
                </https_head>
                <idolnum>
                    198
                </idolnum>
                <isfans>
                    true
                </isfans>
                <isidol>
                    true
                </isidol>
                <isrealname>
                    1
                </isrealname>
                <isvip>
                    0
                </isvip>
                <location>
                    中国 九江
                </location>
                <name>
                    o149484047
                </name>
                <nick>
                    范泽鑫
                </nick>
                <openid>
                    01B5A61F2AFEC00855A914AC44295092
                </openid>
                <province_code>
                    36
                </province_code>
                <sex>
                    1
                </sex>
                <tag>
                    <id>
                        3274154839212534452
                    </id>
                    <name>
                        微博控
                    </name>
                </tag>
                <tag>
                    <id>
                        5317943929679550835
                    </id>
                    <name>
                        企鹅控
                    </name>
                </tag>
                <tag>
                    <id>
                        6357215159807203124
                    </id>
                    <name>
                        Jay迷
                    </name>
                </tag>
                <tag>
                    <id>
                        7209022255400351955
                    </id>
                    <name>
                        我爱手机QQ浏览器
                    </name>
                </tag>
                <tag>
                    <id>
                        8468239602781125813
                    </id>
                    <name>
                        数码控
                    </name>
                </tag>
                <tag>
                    <id>
                        8946946727085816901
                    </id>
                    <name>
                        锋蜜
                    </name>
                </tag>
                <tag>
                    <id>
                        10753364960634565058
                    </id>
                    <name>
                        玉米
                    </name>
                </tag>
                <tag>
                    <id>
                        15657928532735099976
                    </id>
                    <name>
                        尊迷
                    </name>
                </tag>
                <tag>
                    <id>
                        15932857217868104144
                    </id>
                    <name>
                        凉粉
                    </name>
                </tag>
                <tag>
                    <id>
                        17136297143514901751
                    </id>
                    <name>
                        Justin迷
                    </name>
                </tag>
                <tweet>
                    <from>
                        腾讯微博
      

  3.   

    哦哦哦哦  是腾讯微博的个人信息API返回的数据啊如果是json的 就json_decode()就变成数组了,随便取值  xml的我居然不会.... 搭车学习.....
      

  4.   

    http://www.nowamagic.net/librarys/veda/detail/793
      

  5.   

    搜了个方法 
    function xml_to_array( $xml )
    {
        $reg = "/<(\\w+)[^>]*?>([\\x00-\\xFF]*?)<\\/\\1>/";
        if(preg_match_all($reg, $xml, $matches))
        {
            $count = count($matches[0]);
            $arr = array();
            for($i = 0; $i < $count; $i++)
            {
                $key = $matches[1][$i];
                $val = xml_to_array( $matches[2][$i] );  // 递归
                if(array_key_exists($key, $arr))
                {
                    if(is_array($arr[$key]))
                    {
                        if(!array_key_exists(0,$arr[$key]))
                        {
                            $arr[$key] = array($arr[$key]);
                        }
                    }else{
                        $arr[$key] = array($arr[$key]);
                    }
                    $arr[$key][] = $val;
                }else{
                    $arr[$key] = $val;
                }
            }
            return $arr;
        }else{
            return $xml;
        }
    }$str = '<root>
        <data>
            <curnum>
                20
            </curnum>
            <hasnext>
                0
            </hasnext>
            <info>
                <city_code>
                    29
                </city_code>
                <country_code>
                    1
                </country_code>
                <fansnum>
                    100
                </fansnum>
                <head>
                    http://app.qlogo.cn/mbloghead/ec086f8e8265338f812c
                </head>
                <https_head>
                    https://app.qlogo.cn/mbloghead/ec086f8e8265338f812c
                </https_head>
                <idolnum>
                    247
                </idolnum>
                <isfans>
                    true
                </isfans>
                <isidol>
                    true
                </isidol>
                <isrealname>
                    1
                </isrealname>
                <isvip>
                    0
                </isvip>
                <location>
                    中国 大理
                </location>
                <name>
                    shoujini00
                </name>
                <nick>
                    倪旺达
                </nick>
                <openid>
                    DFEE460F0FD097462CFA8576D43E5B01
                </openid>
                <province_code>
                    53
                </province_code>
                <sex>
                    1
                </sex>
                <tag/>
                <tweet>
                    <from>
                        腾讯微博
                    </from>
                    <id>
                        189275000692680
                    </id>
                    <text>
                        克大理闲!
                    </text>
                    <timestamp>
                        1374646496
                    </timestamp>
                </tweet>
            </info>
            <info>
                <city_code>
                    4
                </city_code>
                <country_code>
                    1
                </country_code>
                <fansnum>
                    217
                </fansnum>
                <head>
                    http://app.qlogo.cn/mbloghead/b76a55db336bd8da47e2
                </head>
                <https_head>
                    https://app.qlogo.cn/mbloghead/b76a55db336bd8da47e2
                </https_head>
                <idolnum>
                    198
                </idolnum>
                <isfans>
                    true
                </isfans>
                <isidol>
                    true
                </isidol>
                <isrealname>
                    1
                </isrealname>
                <isvip>
                    0
                </isvip>
                <location>
                    中国 九江
                </location>
                <name>
                    o149484047
                </name>
                <nick>
                    范泽鑫
                </nick>
                <openid>
                    01B5A61F2AFEC00855A914AC44295092
                </openid>
                <province_code>
                    36
                </province_code>
                <sex>
                    1
                </sex>
                <tag>
                    <id>
                        3274154839212534452
                    </id>
                    <name>
                        微博控
                    </name>
                </tag>
                <tag>
                    <id>
                        5317943929679550835
                    </id>
                    <name>
                        企鹅控
                    </name>
                </tag>
                <tag>
                    <id>
                        6357215159807203124
                    </id>
                    <name>
                        Jay迷
                    </name>
                </tag>
                <tag>
                    <id>
                        7209022255400351955
                    </id>
                    <name>
                        我爱手机QQ浏览器
                    </name>
                </tag>
                <tag>
                    <id>
                        8468239602781125813
                    </id>
                    <name>
                        数码控
                    </name>
                </tag>
                <tag>
                    <id>
                        8946946727085816901
                    </id>
                    <name>
                        锋蜜
                    </name>
                </tag>
                <tag>
                    <id>
                        10753364960634565058
                    </id>
                    <name>
                        玉米
                    </name>
                </tag>
                <tag>
                    <id>
                        15657928532735099976
                    </id>
                    <name>
                        尊迷
                    </name>
                </tag>
                <tag>
                    <id>
                        15932857217868104144
                    </id>
                    <name>
                        凉粉
                    </name>
                </tag>
                <tag>
                    <id>
                        17136297143514901751
                    </id>
                    <name>
                        Justin迷
                    </name>
                </tag>
                <tweet>
                    <from>
                        腾讯微博';
    print_r(xml_to_array($str));结果就是一个数组   就可以用了
      

  6.   

    这么多的xml解析工具不用。
    simplexml,xpath,xmlreader.
      

  7.   

    你直接使用json format格式多好,让api给你返回json格式的内容array( "format" => "json",