解决方案 »

  1. $out = array();
    $xml = <<<xml
    <Proxy>
      <ListenPort>8889</ListenPort>
      <NetConnectName>
      </NetConnectName>
      <ValidateProxy2Url>http://www.so.com</ValidateProxy2Url>
      <ValidateProxy2RetrunString>360</ValidateProxy2RetrunString>
      <ValidateTimeOut>5</ValidateTimeOut>
      <IsOrderOrRandomGetProxys>1</IsOrderOrRandomGetProxys>
      <IsADSLReconnect>0</IsADSLReconnect>
      <IsADSLReconnect_IntervalOrContainString>0</IsADSLReconnect_IntervalOrContainString>
      <ReconnectIntervalMinute>90</ReconnectIntervalMinute>
      <ReconnectIfContainString>
      </ReconnectIfContainString>
      <SampleProxySite>
      </SampleProxySite>
      <Level2Proxys>
        <ProxyItem Type="0" IP="5.56.134.44" Port="8080" UserName="" PassWord="" Domain="" IsValidate="1" />
        <ProxyItem Type="0" IP="14.18.17.163" Port="80" UserName="" PassWord="" Domain="" IsValidate="1" />
        <ProxyItem Type="0" IP="14.18.17.166" Port="80" UserName="" PassWord="" Domain="" IsValidate="1" />
     
      </Level2Proxys>
    </Proxy>
    xml;
    $i = 0;
    $str = simplexml_load_string($xml);
    foreach($str->Level2Proxys->ProxyItem as $key=>$value){
    $t = $value->attributes();
    $out[$i]['IP'] = $t['IP'];
    $out[$i]['Port'] = $t['Port'];
    $i++;
    }
    print_r($out);
      

  2. 现成的xml类不错。
    不过二次split也可以做到。
      

  3. <ProxyItem Type="0" IP="5.56.134.44" Port="8080" UserName="" PassWord="" Domain="" IsValidate="1" />
        <ProxyItem Type="0" IP="14.18.17.163" Port="80" UserName="" PassWord="" Domain="" IsValidate="1" />
        这种现成的类读取不到啊
      

  4. prin_r(simplexml_load_string($xml);看看就知道怎么做了
      

类似问题 »