質問編集履歴
2
取得するXML、取得するPHPコードの詳細追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,15 +15,23 @@
|
|
15
15
|
### 該当のソースコード
|
16
16
|
|
17
17
|
```XML
|
18
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
19
|
+
<entry>
|
18
|
-
<title>Test</title>
|
20
|
+
<title>Test</title>
|
19
|
-
<content:encoded>
|
21
|
+
<content:encoded>
|
20
|
-
|
22
|
+
<img src="https://hoge.jpg"/>
|
21
|
-
</content:encoded>
|
23
|
+
</content:encoded>
|
24
|
+
</entry>
|
25
|
+
</feed>
|
22
26
|
```
|
23
27
|
```PHP
|
24
|
-
$title = (string)$item->title;
|
25
|
-
$
|
28
|
+
$rss_data = @simplexml_load_string($xml,'SimpleXMLElement', LIBXML_NOCDATA);
|
26
29
|
|
30
|
+
foreach($rss_data->entry as $item) {
|
31
|
+
$title = (string)$item->title;
|
32
|
+
$image = (string)$item->children("http://purl.org/rss/1.0/modules/content/")->encoded;
|
33
|
+
}
|
34
|
+
|
27
35
|
var_dump($title);
|
28
36
|
var_dump($image);
|
29
37
|
```
|
1
詳細の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
### 発生している問題・エラーメッセージ
|
9
9
|
|
10
10
|
```PHP
|
11
|
+
string(4) "Test"
|
11
12
|
string(2) " "
|
12
13
|
```
|
13
14
|
|
@@ -22,6 +23,9 @@
|
|
22
23
|
```PHP
|
23
24
|
$title = (string)$item->title;
|
24
25
|
$image = (string)$item->children("http://purl.org/rss/1.0/modules/content/")->encoded;
|
26
|
+
|
27
|
+
var_dump($title);
|
28
|
+
var_dump($image);
|
25
29
|
```
|
26
30
|
|
27
31
|
### 試したこと
|