0

私のxmlフライ:

<item>
<title geoid="1198">District of Columbia</title>
<description cong_dist="Delegate District (at Large) 98">DC - Delegate District (at Large) 98 <br/> No of Incidents: 1436</description>
<latitude>38.8933115</latitude>
<longitude>-77.0146475</longitude>
<georss:polygon>38.934311 -77.1199 38.939834989364 -77.112868886998 38.94641 -77.1045 38.94891 -77.1007 38.95651 -77.0915 38.960871062931 -77.085827416011 38.967245703105 -77.077535703105 38.971616050926 -77.07185104194 38.98511 -77.054299 38.986557824794 -77.052373393024 38.99511 -77.040999 38.99171 -77.036299 38.98423067065 -77.026499658425 38.977828623846 -76.909395 38.895811472659 -76.913155644266 38.904084963804 -76.923528686655 38.904209815545 -76.923685221832 38.910455906543 -76.931516373827 38.913311 -76.935096 38.918592133391 -76.941928356721 38.930758817183 -76.957668751373 38.93511031877 -76.963298416241 38.946183221387 -76.977623754198 38.951906165093 -76.985027693844 38.95742281319 -76.992164742828 38.961159688178 -76.99699924729 38.96541 -77.002498 38.97011 -77.008298 38.97441 -77.013798 38.97591 -77.015598 38.977828623846 -77.018111761535 38.98423067065 -77.026499658425 38.99171 -77.036299 38.99511 -77.040999 38.986557824794 -77.052373393024 38.98511 -77.054299 38.971616050926 -77.07185104194 38.967245703105 -77.077535703105 38.960871062931 -77.085827416011 38.95651 -77.0915 38.94891 -77.1007 38.94641 -77.1045 38.939834989364 -77.112868886998 38.934311 -77.1199</georss:polygon>
</item>

私はこの値をdc.xmlfile

変数内のすべての値を取得する方法。たとえば、タグの値は、php の $lat 変数に格納されます。

この値を取得するには、あなたの親切な助けが必要です...、

4

2 に答える 2

2

これを試してみてください

<?php
$string = <<<XML
<?xml version='1.0'?>
<item>
<title geoid="1198">District of Columbia</title>
<description cong_dist="Delegate District (at Large) 98">DC - Delegate District (at Large) 98 <br/> No of Incidents: 1436</description>
<latitude>38.8933115</latitude>
<longitude>-77.0146475</longitude>
<georss:polygon>38.934311 -77.1199 38.939834989364 -77.112868886998 38.94641 -77.1045 38.94891 -77.1007 38.95651 -77.0915 38.960871062931 -77.085827416011 38.967245703105 -77.077535703105 38.971616050926 -77.07185104194 38.98511 -77.054299 38.986557824794 -77.052373393024 38.99511 -77.040999 38.99171 -77.036299 38.98423067065 -77.026499658425 38.977828623846 -76.909395 38.895811472659 -76.913155644266 38.904084963804 -76.923528686655 38.904209815545 -76.923685221832 38.910455906543 -76.931516373827 38.913311 -76.935096 38.918592133391 -76.941928356721 38.930758817183 -76.957668751373 38.93511031877 -76.963298416241 38.946183221387 -76.977623754198 38.951906165093 -76.985027693844 38.95742281319 -76.992164742828 38.961159688178 -76.99699924729 38.96541 -77.002498 38.97011 -77.008298 38.97441 -77.013798 38.97591 -77.015598 38.977828623846 -77.018111761535 38.98423067065 -77.026499658425 38.99171 -77.036299 38.99511 -77.040999 38.986557824794 -77.052373393024 38.98511 -77.054299 38.971616050926 -77.07185104194 38.967245703105 -77.077535703105 38.960871062931 -77.085827416011 38.95651 -77.0915 38.94891 -77.1007 38.94641 -77.1045 38.939834989364 -77.112868886998 38.934311 -77.1199</georss:polygon>
</item>
XML;

$xml = simplexml_load_string($string);
$title = $xml->title;
print_r($title);
?>
于 2013-01-30T05:49:53.503 に答える
1

このスクリーンショットを見てください。あなたが言っていることはまったくエラーではありませんここに画像の説明を入力

于 2013-01-30T06:16:52.213 に答える