이것에 대한 몇 가지 다른 게시물을 살펴 보았지만 기쁨은 없습니다.PHP에서 XML 속성 얻기
이 코드있어 :
$url = "http://itunes.apple.com/us/rss/toppaidapplications/limit=10/genre=6014/xml";
$string = file_get_contents($url);
$string = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $string);
$xml = simplexml_load_string($string);
foreach ($xml->entry as $val) {
echo "RESULTS: " . $val->attributes() . "\n";
을하지만 난 어떤 결과를 얻을 수 없습니다.
<id im:id="549592189" im:bundleId="com.activision.wipeout">http://itunes.apple.com/us/app/wipeout/id549592189?mt=8&uo=2</id>
어떤 제안 : 나는이 조각에 549,592,189 될 것 ID 값을 얻기에 특히 관심이 있어요? xpath
와
정규식가 무엇입니까? – Herbert
regexes로 html/xml을 조작하지 마십시오. 너는 단지 곤경에 구걸 중이다. –
[구문 분석 Html Cthulhu 방법] (http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhuway.html)을 읽어야합니다. 그것은 html에 관한 것이지만 xml도 적용됩니다. – ShadowScripter