2012-03-22 16 views
-1

xmlドキュメントを解析できません。 よく私の仕事は、私はそれをxmlデータを解析できません

$book = simplexml_load_string($datax); 
$ipadd = $book->ip_address; 
$ipatype = $book->ip_type; 
$ip_routing_type = $book->Network->ip_routing_type; 
$state = $book->Location->StateData->state; 
$country = $book->Location->CountryData->country; 
$continent = $book->Location->continent; 
$region = $book->Location->region; 

今取得していますいくつかのエラー 1)エンティティを解析しようと、私は、IP情報

<ip_address>209.59.194.20</ip_address><ip_type>Mapped</ip_type><Network><organization>thoughtconvergence.com</organization><carrier>whidbey internet services</carrier><asn>6295</asn><connection_type/><line_speed/><ip_routing_type>fixed</ip_routing_type><Domain><tld>com</tld><sld>trafficz</sld></Domain></Network><Location><continent>north america</continent><latitude>34.03708</latitude><longitude>-118.42789</longitude><CountryData><country>united states</country><country_code>us</country_code><country_cf>99</country_cf></CountryData><region>southwest</region><StateData><state>california</state><state_code>ca</state_code><state_cf>80</state_cf></StateData><dma>803</dma><msa>31100</msa><CityData><city>los angeles</city><postal_code>90064</postal_code><time_zone>-8</time_zone><area_code>323</area_code><city_cf>61</city_cf></CityData></Location></ipinfo> 

が含まれているカールからXMLページを持っている

のようでした。 2行目:パーサーエラー:文書末尾の余分な内容 2行内のオブジェクト以外のプロパティを取得しようとしています。

答えて

3

あなたのXMLは無効です。これは、データ

</ipinfo> 

の終わりに、ルート要素の終了タグを有しているがないヘッダ・タグは存在しません。あなたがタックの場合:

<ipinfo> 

私はそれがうまくいくと思います。

+0

ありがとう.....私たちはいつか忘れてしまい、問題を起こす:D – user114500

関連する問題